Feat : Cloud SQL SocketFactory 의존성 추가 #204
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 to Cloud Run | |
| on: | |
| push: | |
| permissions: | |
| contents: read | |
| env: | |
| REGION: asia-northeast3 | |
| SERVICE: tinybite-server | |
| IMAGE: asia-northeast3-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/tinybite/tinybite-server | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # -------------------------- | |
| # 1) Checkout | |
| # -------------------------- | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| # -------------------------- | |
| # 2) JDK 설정 | |
| # -------------------------- | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: gradle | |
| # -------------------------- | |
| # 3) 빌드 전 리소스 파일 생성 | |
| # -------------------------- | |
| - name: Create FCM key file | |
| run: | | |
| mkdir -p src/main/resources | |
| echo '${{ secrets.FCM_SERVICE_ACCOUNT }}' > src/main/resources/tinybite_fcm.json | |
| # -------------------------- | |
| # 4) Gradle 빌드 | |
| # -------------------------- | |
| - name: Build JAR | |
| run: | | |
| chmod +x ./gradlew | |
| ./gradlew clean bootJar -x test | |
| cp $(ls build/libs/*.jar | grep -v plain | head -n 1) app.jar | |
| # -------------------------- | |
| # 5) GCP 인증 | |
| # -------------------------- | |
| - name: Authenticate to GCP | |
| uses: google-github-actions/auth@v2 | |
| with: | |
| credentials_json: ${{ secrets.GCP_SA_KEY }} | |
| - name: Set up Cloud SDK | |
| uses: google-github-actions/setup-gcloud@v2 | |
| # -------------------------- | |
| # 6) Docker → Artifact Registry push | |
| # -------------------------- | |
| - name: Configure Docker for Artifact Registry | |
| run: gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev --quiet | |
| - name: Build & Push Docker image | |
| run: | | |
| docker build -t ${{ env.IMAGE }}:${{ github.sha }} -t ${{ env.IMAGE }}:latest . | |
| docker push ${{ env.IMAGE }}:${{ github.sha }} | |
| docker push ${{ env.IMAGE }}:latest | |
| # -------------------------- | |
| # 7) .env 파일 생성 | |
| # -------------------------- | |
| - name: Create .env file | |
| run: printf "%s" "${{ secrets.ENV_FILE }}" > .env | |
| # -------------------------- | |
| # 8) Cloud Run 배포 | |
| # -------------------------- | |
| - name: Deploy to Cloud Run | |
| run: | | |
| gcloud run deploy ${{ env.SERVICE }} \ | |
| --image ${{ env.IMAGE }}:${{ github.sha }} \ | |
| --region ${{ env.REGION }} \ | |
| --platform managed \ | |
| --allow-unauthenticated \ | |
| --port 8080 \ | |
| --add-cloudsql-instances ${{ secrets.GCP_PROJECT_ID }}:${{ env.REGION }}:tinybite \ | |
| --env-vars-file .env | |
| - name: Deploy URL | |
| run: | | |
| echo "✅ 배포 완료" | |
| gcloud run services describe ${{ env.SERVICE }} \ | |
| --region ${{ env.REGION }} \ | |
| --format 'value(status.url)' |