Skip to content

Instantly share code, notes, and snippets.

@mikefrancis
Created November 20, 2025 08:59
Show Gist options
  • Select an option

  • Save mikefrancis/eab498359f75d868c1214c9614b29212 to your computer and use it in GitHub Desktop.

Select an option

Save mikefrancis/eab498359f75d868c1214c9614b29212 to your computer and use it in GitHub Desktop.
GCP
name: Deploy to GCP
on:
push:
branches:
- main
env:
GCP_PROJECT_ID: some-project-id
GCP_REGION: europe-west1 # this has a different region as it's the closest where you can do domain mappings
SERVICE_NAME: api
APP_ENV: production
ARTIFACT_REGISTRY: europe-west2-docker.pkg.dev
ARTIFACT_REPOSITORY: team-name
jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
# environment: ${{ env.APP_ENV }}
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Configure GCP credentials
uses: google-github-actions/auth@v3
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Configure Docker for GCR
run: gcloud auth configure-docker ${{ env.ARTIFACT_REGISTRY }}
- name: Build and push Docker image to GCR
run: |
docker build -t ${{ env.ARTIFACT_REGISTRY }}/${{ env.GCP_PROJECT_ID }}/${{ env.ARTIFACT_REPOSITORY }}/${{ env.SERVICE_NAME }}:${{ github.sha }} .
docker push ${{ env.ARTIFACT_REGISTRY }}/${{ env.GCP_PROJECT_ID }}/${{ env.ARTIFACT_REPOSITORY }}/${{ env.SERVICE_NAME }}:${{ github.sha }}
- id: "deploy"
uses: "google-github-actions/deploy-cloudrun@v3"
with:
region: ${{ env.GCP_REGION }}
service: ${{ env.SERVICE_NAME }}-${{ env.APP_ENV }}
image: "${{ env.ARTIFACT_REGISTRY }}/${{ env.GCP_PROJECT_ID }}/${{ env.ARTIFACT_REPOSITORY }}/${{ env.SERVICE_NAME }}:${{ github.sha }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment