File tree Expand file tree Collapse file tree 1 file changed +56
-0
lines changed
Expand file tree Collapse file tree 1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Deploy to GCP
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ paths-ignore :
8+ - ' .github/workflows/**'
9+
10+ jobs :
11+ deploy :
12+ runs-on : ubuntu-latest
13+ permissions :
14+ id-token : write
15+ contents : read
16+ steps :
17+ - uses : actions/checkout@v4
18+
19+ # CI에서 생성한 JAR 파일 다운로드
20+ - name : Download JAR Artifact
21+ uses : actions/download-artifact@v4
22+ with :
23+ name : application-jar
24+ path : build/libs/
25+
26+ - name : Login to DockerHub
27+ uses : docker/login-action@v3
28+ with :
29+ username : ${{ secrets.DOCKER_USERNAME }}
30+ password : ${{ secrets.DOCKER_PASSWORD }}
31+
32+ - name : Build & Push Docker Image
33+ uses : docker/build-push-action@v6
34+ with :
35+ push : true
36+ context : .
37+ tags : ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:latest
38+
39+ - name : Authenticate to GCP
40+ uses : google-github-actions/auth@v2
41+ with :
42+ workload_identity_provider : ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}
43+ service_account : ${{ secrets.SERVICE_ACCOUNT_EMAIL }}
44+
45+ - name : Deploy to GCP Compute Engine
46+ uses : google-github-actions/ssh-compute@v1
47+ with :
48+ instance_name : ${{ secrets.GCP_INSTANCE_NAME }}
49+ zone : ${{ secrets.GCP_INSTANCE_ZONE }}
50+ ssh_private_key : ${{ secrets.GCP_SSH_PRIVATE_KEY }}
51+ command : |
52+ cd /app/${{ github.repository }}
53+ sudo curl -o docker-compose.yml https://raw.githubusercontent.com/${{ github.repository }}/main/docker-compose.yml
54+ sudo docker-compose down
55+ sudo docker-compose up -d ${{ secrets.DOCKER_IMAGE_NAME }}
56+ sudo docker image prune -a -f
You can’t perform that action at this time.
0 commit comments