66 push :
77 branches :
88 - ' develop/be'
9- - ' feature/#517-oracle-cicd '
9+ - " setting/#542-oracle_cloud "
1010 paths :
1111 - ' backend/**'
1212 - ' .github/workflows/**'
@@ -32,13 +32,16 @@ jobs:
3232 uses : gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
3333
3434 - name : Cache Gradle dependencies
35- uses : actions/cache@v4 # Gradle 의존성 캐시 설정
35+ uses : actions/cache@v4
3636 with :
37- path : ~/.gradle/caches # Gradle 캐시 경로
38- key : ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} # Gradle 파일 해시값 기반 키
37+ path : |
38+ ~/.gradle/caches
39+ ~/.gradle/wrapper
40+ key : ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
3941 restore-keys : |
4042 ${{ runner.os }}-gradle-
4143
44+
4245 - name : make application.properties
4346 run : |
4447 cd ./backend/src/main/resources
@@ -51,31 +54,13 @@ jobs:
5154 run : |
5255 cd backend
5356 ./gradlew clean build -x test
54-
55- - id : ' auth'
56- uses : ' google-github-actions/auth@v2'
57- with :
58- credentials_json : ${{ secrets.GCE_SA_KEY }}
59-
60- # GCloud SDK 캐시 설정
61- - name : Cache Google Cloud SDK
62- uses : actions/cache@v4
63- with :
64- path : ~/.cache
65- key : gcloud-sdk-${{ runner.os }}
66- restore-keys : |
67- gcloud-sdk-
68-
69- # Google Cloud CLI 설정
70- - name : Set up Google Cloud SDK
71- uses : google-github-actions/setup-gcloud@v2
57+
58+ - name : Log in to Docker Hub
59+ uses : docker/login-action@v2
7260 with :
73- project_id : ${{ secrets.GCE_PROJECT }}
61+ username : ${{ secrets.SERVER_DOCKER_USERNAME }}
62+ password : ${{ secrets.SERVER_DOCKER_PASSWORD }}
7463
75- # Docker 인증
76- - name : Authenticate Docker to Google Cloud Container Registry (GCR)
77- run : |
78- gcloud auth configure-docker asia-northeast3-docker.pkg.dev
7964
8065 # Docker 이미지 빌드 및 GCR 업로드
8166 # ARM 전용 이미지 배포
@@ -103,17 +88,11 @@ jobs:
10388
10489 steps :
10590
106- # gcloud-setup workflow 호출
107- - id : ' auth'
108- uses : ' google-github-actions/auth@v2'
109- with :
110- credentials_json : ${{ secrets.GCE_SA_KEY }}
111-
112- # Google Cloud CLI 설정
113- - name : Set up Google Cloud SDK
114- uses : google-github-actions/setup-gcloud@v2
91+ - name : Log in to Docker Hub
92+ uses : docker/login-action@v2
11593 with :
116- project_id : ${{ secrets.GCE_PROJECT }}
94+ username : ${{ secrets.SERVER_DOCKER_USERNAME }}
95+ password : ${{ secrets.SERVER_DOCKER_PASSWORD }}
11796
11897 # oracle ssh 접속 후 배포
11998 - name : Update Container on VM
@@ -124,13 +103,6 @@ jobs:
124103 key : ${{ secrets.ORACLE_INSTANCE_DEV_PRIVATE_KEY }}
125104 port : ${{ secrets.ORACLE_INSTANCE_DEV_PORT }}
126105 script : |
127- gcloud auth activate-service-account --key-file=/home/${{ secrets.ORACLE_INSTANCE_USER }}/gce_sa_key.json
128- ACCESS_TOKEN=$(gcloud auth print-access-token)
129- docker login -u oauth2accesstoken --password-stdin https://asia-northeast3-docker.pkg.dev
130- docker pull asia-northeast3-docker.pkg.dev/pristine-valve-457508-k7/moadong/moadong-dev:latest
131-
132- sudo usermod -aG docker $USER
133- newgrp docker
134106 docker pull ${{ secrets.DOCKER_IMAGE_DEV }}:latest
135107
136108 export USERNAME=${{ secrets.ORACLE_INSTANCE_USER }}
0 commit comments