fix: gradle.yml #31
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: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: make application.yml | |
run: | | |
mkdir -p ./infinity-api/src/main/resources | |
touch ./infinity-api/src/main/resources/application.yml | |
echo "${{ secrets.APPLICATION }}" > ./infinity-api/src/main/resources/application.yml | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Build with Gradle | |
run: ./gradlew :infinity-api:build -x test --parallel | |
- name: Docker build | |
run: | | |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker build -t ${{ secrets.DOCKER_USERNAME }}/grow:latest . | |
docker push ${{ secrets.DOCKER_USERNAME }}/grow:latest | |
- name: Deploy with SSH | |
if: github.ref == 'refs/heads/main' | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} # EC2 인스턴스 퍼블릭 DNS | |
username: ubuntu | |
key: ${{ secrets.PRIVATE_KEY }} # pem 키 | |
# 도커 작업 | |
script: | | |
sudo docker stop $(docker ps -a -q) | |
sudo docker rm $(docker ps --filter 'status=exited' -a -q) | |
sudo docker image prune -a -f | |
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/grow:latest | |
sudo docker run -d --name grow_app --log-driver=syslog -p 80:8080 \ | |
${{ secrets.DOCKER_USERNAME }}/grow:latest |