Skip to content

Commit a09a50f

Browse files
authored
Update gradle.yml
1 parent ffd78e4 commit a09a50f

File tree

1 file changed

+46
-10
lines changed

1 file changed

+46
-10
lines changed

.github/workflows/gradle.yml

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,52 @@ jobs:
3636
- name: Build with Gradle Wrapper
3737
run: ./gradlew build
3838

39-
# NOTE: The Gradle Wrapper is the default and recommended way to run Gradle (https://docs.gradle.org/current/userguide/gradle_wrapper.html).
40-
# If your project does not have the Gradle Wrapper configured, you can use the following configuration to run Gradle with a specified version.
41-
#
42-
# - name: Setup Gradle
43-
# uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
44-
# with:
45-
# gradle-version: '8.9'
46-
#
47-
# - name: Build with Gradle 8.9
48-
# run: gradle build
39+
# 3. 도커허브 로그인
40+
- name: Login to DockerHub
41+
uses: docker/login-action@v3
42+
with:
43+
username: ${{ secrets.DOCKER_USERNAME }}
44+
password: ${{ secrets.DOCKER_PASSWORD }}
45+
46+
# 4. 도커 허브에 이미지 푸시
47+
- name: Push Docker Image
48+
uses: docker/build-push-action@v6
49+
with:
50+
push: true
51+
context: .
52+
tags: ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:latest
53+
54+
# 5. GCP 인증
55+
- name: Authenticate to GCP
56+
id: 'auth'
57+
uses: 'google-github-actions/auth@v2'
58+
with:
59+
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }} # 생성한 워크로드 아이덴티티 풀의 ID
60+
service_account: ${{ secrets.SERVICE_ACCOUNT_EMAIL }} # IAM 서비스 계정
61+
62+
# 6. GCP Compute Engine SSH로 배포
63+
- name: Deploy to GCP Compute Engine
64+
id: 'compute-ssh'
65+
uses: 'google-github-actions/ssh-compute@v1'
66+
with:
67+
instance_name: ${{ secrets.GCP_INSTANCE_NAME }}
68+
zone: ${{ secrets.GCP_INSTANCE_ZONE }}
69+
ssh_private_key: ${{ secrets.GCP_SSH_PRIVATE_KEY }}
70+
command: |
71+
mkdir ./${{ github.repository }}
72+
cd ./${{ github.repository }}
73+
ls -al
74+
sudo curl -o docker-compose.yml https://raw.githubusercontent.com/${{ github.repository }}/main/docker-compose.yml
75+
sudo docker-compose down
76+
sudo docker-compose up -d ${{ secrets.DOCKER_IMAGE_NAME }}
77+
sudo docker image prune -a -f
78+
79+
# Example of using the output
80+
- id: 'debug'
81+
run: |-
82+
echo '${{ steps.compute-ssh.outputs.stdout }}'
83+
echo '${{ steps.compute-ssh.outputs.stderr }}'
84+
4985
5086
dependency-submission:
5187

0 commit comments

Comments
 (0)