fix : github actions #62
Workflow file for this run
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/CD with Gradle | |
on: | |
push: | |
branches: [ "CHAT-63-DevOps-ToolChain" ] | |
pull_request: | |
branches: [ "CHAT-63-DevOps-ToolChain" ] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
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' | |
- name: Build with Gradle | |
run: ./gradlew --warning-mode all build -i | |
docker-build: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Grant execute permisson for gradlew | |
run: chmod +x gradlew | |
- name: Build with Gradle (without Test) | |
run: ./gradlew clean build -x test --stacktrace | |
- name: Docker Hub build & push | |
run: | | |
docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} -p ${{ secrets.DOCKER_PWD }} | |
docker build -t chatdiary/chatdiary-image:latest . | |
docker images | |
docker push chatdiary/chatdiary-image:latest | |
- name: deploy | |
uses: appleboy/ssh-action@master | |
with: | |
username: ec2-user | |
host: ${{ secrets.HOST }} | |
key: ${{ secrets.PRIVATE_KEY }} | |
port: ${{secrets.PORT}} | |
script: | | |
docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} -p ${{ secrets.DOCKER_PWD }} | |
sudo docker rm -f $(sudo docker ps -qa) | |
sudo docker run -d --name server -p 8080:8080 chatdiary/chatdiary-image:latest |