Hotfix : cloud run으로 변경 #179
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: | |
| branches: [ main ] | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v3 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| - name: Create .env file | |
| run: echo "${{ secrets.ENV_FILE }}" > .env | |
| - name: Create FCM key file | |
| run: echo "${{ secrets.FCM_SERVICE_ACCOUNT }}" > src/main/resources/firebase-adminsdk.json | |
| - name: Build with Gradle | |
| run: | | |
| chmod +x gradlew | |
| ./gradlew clean build -x test | |
| - name: Authenticate to GCP | |
| uses: google-github-actions/auth@v1 | |
| with: | |
| credentials_json: ${{ secrets.GCP_SA_KEY }} | |
| # Docker 이미지 빌드 & GCR 푸시 | |
| - name: Build and Push Docker image | |
| run: | | |
| gcloud auth configure-docker | |
| docker build -t gcr.io/${{ secrets.GCP_PROJECT_ID }}/my-app:${{ github.sha }} . | |
| docker push gcr.io/${{ secrets.GCP_PROJECT_ID }}/my-app:${{ github.sha }} | |
| # Cloud Run 배포 (Compute Engine이랑 다른 부분) | |
| - name: Deploy to Cloud Run | |
| run: | | |
| gcloud run deploy my-app \ | |
| --image gcr.io/${{ secrets.GCP_PROJECT_ID }}/my-app:${{ github.sha }} \ | |
| --region asia-northeast3 \ | |
| --platform managed \ | |
| --allow-unauthenticated \ | |
| --port 8080 |