Chore : google sql 의존성 추가 #197
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 GCP | |
| on: | |
| push: | |
| branches: ["main"] | |
| permissions: | |
| contents: read | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| - name: Create FCM key file | |
| run: | | |
| mkdir -p src/main/resources | |
| echo '${{ secrets.FCM_SERVICE_ACCOUNT }}' > src/main/resources/firebase-adminsdk.json | |
| - name: Create .env file | |
| shell: bash | |
| run: printf "%s" "${{ secrets.ENV_FILE }}" > .env | |
| - 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 | |
| # -------------------------- | |
| # 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 | |
| # -------------------------- | |
| # Artifact Registry에 push | |
| # -------------------------- | |
| - name: Configure Docker for Artifact Registry | |
| run: gcloud auth configure-docker ${{ secrets.GCP_REGION }}-docker.pkg.dev | |
| - name: Build & Push Docker image | |
| run: | | |
| IMAGE=${{ secrets.GCP_REGION }}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.AR_REPOSITORY }}/tinybite-server:${{ github.sha }} | |
| docker build -t $IMAGE . | |
| docker push $IMAGE | |
| echo "IMAGE=$IMAGE" >> $GITHUB_ENV | |
| # -------------------------- | |
| # Cloud Run 배포 | |
| # -------------------------- | |
| - name: Deploy to Cloud Run | |
| run: | | |
| gcloud run deploy tinybite-server \ | |
| --image $IMAGE \ | |
| --region ${{ secrets.GCP_REGION }} \ | |
| --platform managed \ | |
| --allow-unauthenticated \ | |
| --env-vars-file .env |