This file contains hidden or 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: CD with Gradle | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest # Github Actions의 워크플로워 runner 환경 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| - name: Build with Gradle Wrapper -> jar 파일 생성 | |
| run: | | |
| chmod 544 ./gradlew | |
| ./gradlew build -x test | |
| - name: Transfer Build File using SCP -> jar 파일 원격 서버 복사 | |
| uses: appleboy/scp-action@master # .jar 파일 원격 서버로 복사 | |
| with: | |
| username: ubuntu | |
| host: ${{ secrets.SSH_HOST }} | |
| key: ${{ secrets.SSH_KEY }} | |
| source: "build/libs/*.jar" # Github Actions 워크플로우가 실행되는 runner환경에서의 경로 | |
| target: "/home/ubuntu/hackathon/build/libs/" # 원격 서버 파일 경로 | |
| - name: docker compose up -> make (mysql,spring, nginx) | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.SSH_HOST }} | |
| username: ubuntu | |
| key: ${{ secrets.SSH_KEY }} | |
| script: | | |
| cd ~/hackathon | |
| docker compose up -d --build --no-deps spring | |
| docker image prune -f | |