feat: add GitHub Actions workflow for deploying to Google Cloud Run #1
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 Google Cloud Run | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - master | |
| env: | |
| PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} | |
| SERVICE_NAME: fairforge-arena | |
| REGION: us-central1 | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v3 | |
| - name: Authenticate to Google Cloud | |
| id: auth | |
| uses: google-github-actions/auth@v1 | |
| with: | |
| credentials_json: ${{ secrets.GCP_SA_KEY }} | |
| - name: Set up Google Cloud SDK | |
| uses: google-github-actions/setup-gcloud@v1 | |
| - name: Configure Docker Authentication | |
| run: gcloud auth configure-docker gcr.io | |
| - name: Build and Push Docker Image | |
| run: | | |
| docker build -t gcr.io/$PROJECT_ID/$SERVICE_NAME:${{ github.sha }} . | |
| docker push gcr.io/$PROJECT_ID/$SERVICE_NAME:${{ github.sha }} | |
| - name: Deploy to Cloud Run | |
| id: deploy | |
| uses: google-github-actions/deploy-cloudrun@v1 | |
| with: | |
| service: ${{ env.SERVICE_NAME }} | |
| region: ${{ env.REGION }} | |
| image: gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE_NAME }}:${{ github.sha }} | |
| env_vars: | | |
| PORT=8080 | |
| flags: '--allow-unauthenticated' | |
| - name: Output Deployment URL | |
| run: echo "Deployed successfully! Application is live at ${{ steps.deploy.outputs.url }}" |