fix: docker image name lower case #11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Java CI with Gradle | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
permissions: | |
contents: read | |
jobs: | |
build-docker-image: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
# Convert line endings to Unix format | |
- name: Convert line endings to Unix | |
run: | | |
sudo apt-get install dos2unix | |
dos2unix ./gradlew | |
- name: Grant execute permission for gradlew | |
run: chmod +x ./gradlew | |
- name: Build with Gradle | |
run: ./gradlew clean bootJar | |
- name: Docker image build | |
run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/cogoserver . | |
- name: Docker login | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Docker Hub push | |
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/cogoserver | |
run-docker-image-on-ec2: | |
needs: build-docker-image | |
runs-on: self-hosted | |
steps: | |
- name: Docker pull | |
run: sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/cogoserver | |
- name: Docker stop container | |
run: sudo docker stop $(sudo docker ps -q) 2>/dev/null || true | |
- name: Docker run new container | |
run: sudo docker run --name github-actions-demo --rm -d -p 8080:8080 ${{ secrets.DOCKERHUB_USERNAME }}/cogoserver | |
- name: Delete old docker image | |
run: sudo docker system prune -f | |