FEAT: test6 #6
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: Deploy | |
| on: | |
| push: | |
| branches: | |
| - deploy | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: GitHub repo 불러오기 | |
| uses: actions/checkout@v4 | |
| - name: JDK 17 버전 설치 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: temurin | |
| java-version: 17 | |
| - name: application.yml 생성 | |
| run: echo "${{ secrets.APPLICATION_PROPERTIES }}" > ./src/main/resources/application.yml | |
| - name: 실행 권한 부여 | |
| run: chmod +x ./gradlew | |
| - name: 테스트 및 빌드 | |
| run: ./gradlew clean build | |
| - name: Google Cloud SDK 설정 | |
| uses: "google-github-actions/auth@v2" | |
| with: | |
| credentials_json: ${{ secrets.GCP_SA_KEY }} | |
| - name: Docker를 위한 gcloud 인증 설정 | |
| run: gcloud auth configure-docker asia-northeast3-docker.pkg.dev | |
| - name: Docker 이미지 생성 및 태그 설정 | |
| run: docker build -t asia-northeast3-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/docker-image/opendata:latest . | |
| - name: Docker 이미지 푸시 | |
| run: docker push asia-northeast3-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/docker-image/opendata:latest | |
| - name: SSH로 GCE에 접속하여 배포 | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.GCE_HOST }} | |
| username: ${{ secrets.GCE_USERNAME }} | |
| key: ${{ secrets.GCE_PRIVATE_KEY }} | |
| script_stop: true | |
| script: | | |
| cd /home/${{ secrets.GCE_USERNAME }} | |
| sudo docker compose down || true | |
| sudo docker pull asia-northeast3-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/docker-image/opendata:latest | |
| sudo docker compose -f compose.yml up -d --build | |