Gaming Assistant: Deploy to 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: "Gaming Assistant: Deploy to Cloud Run" | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - "ai-gaming-assistant-agent/**" | |
| workflow_dispatch: | |
| env: | |
| PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} | |
| GAR_LOCATION: us-central1 | |
| REPOSITORY: videogames-assistant-repo | |
| SERVICE: videogames-assistant | |
| REGION: us-central1 | |
| defaults: | |
| run: | |
| working-directory: ai-gaming-assistant-agent | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Google Auth | |
| id: auth | |
| uses: google-github-actions/auth@v2 | |
| with: | |
| token_format: "access_token" | |
| workload_identity_provider: ${{ secrets.WIF_PROVIDER }} | |
| service_account: ${{ secrets.WIF_SERVICE_ACCOUNT }} | |
| - name: Docker Auth to Artifact Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.GAR_LOCATION }}-docker.pkg.dev | |
| username: oauth2accesstoken | |
| password: ${{ steps.auth.outputs.access_token }} | |
| - name: Build Docker image | |
| run: | | |
| docker build \ | |
| -t "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }}" \ | |
| -t "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.SERVICE }}:latest" \ | |
| . | |
| - name: Push Docker image | |
| run: | | |
| docker push "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }}" | |
| docker push "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.SERVICE }}:latest" | |
| - name: Deploy to Cloud Run | |
| id: deploy | |
| uses: google-github-actions/deploy-cloudrun@v2 | |
| with: | |
| service: ${{ env.SERVICE }} | |
| region: ${{ env.REGION }} | |
| image: "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }}" | |
| flags: | | |
| --allow-unauthenticated | |
| --memory=1Gi | |
| --cpu=1 | |
| --min-instances=0 | |
| --max-instances=10 | |
| --timeout=300s | |
| env_vars: | | |
| GOOGLE_CLOUD_PROJECT=${{ env.PROJECT_ID }} | |
| GOOGLE_CLOUD_LOCATION=${{ env.REGION }} | |
| GOOGLE_GENAI_USE_VERTEXAI=True | |
| SERVE_WEB_INTERFACE=true | |
| secrets: | | |
| ARIZE_API_KEY=ARIZE_API_KEY:latest | |
| ARIZE_SPACE_ID=ARIZE_SPACE_ID:latest | |
| - name: Output URL | |
| run: | | |
| echo "## Deployment Successful! :rocket:" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Service URL:** ${{ steps.deploy.outputs.url }}" >> $GITHUB_STEP_SUMMARY |