fix: git workflow #9
This file contains 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: Build, Push, and Deploy to Cloud Run | |
on: | |
push: | |
branches: | |
- main | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
build-push-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout the repository | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
# Get the short SHA for tagging | |
- name: Get Short SHA | |
id: sha | |
run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
# Authenticate with Google Cloud using Workload Identity Federation | |
- name: Authenticate to Google Cloud | |
uses: google-github-actions/auth@v1 | |
with: | |
workload_identity_provider: 'projects/${{ secrets.GCP_PROJECT_NUMBER }}/locations/global/workloadIdentityPools/github-pool/providers/github-provider' | |
service_account: 'github-actions-sa@${{ secrets.GCP_PROJECT_ID }}.iam.gserviceaccount.com' | |
# Configure Docker to use Google Artifact Registry | |
- name: Configure Docker | |
run: | | |
gcloud auth configure-docker us-east1-docker.pkg.dev | |
# Build and Push Docker Image | |
- name: Build and Push Docker Image | |
run: | | |
IMAGE="us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/sp1-prover/sp1-prover:${{ env.sha }}" | |
echo "Building image: $IMAGE" | |
docker build -t $IMAGE . | |
docker push $IMAGE | |
# Deploy to Cloud Run | |
- name: Deploy to Cloud Run | |
run: | | |
IMAGE="us-east1-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/sp1-prover/sp1-prover:${{ env.sha }}" | |
gcloud run deploy sp1-prover-service \ | |
--image $IMAGE \ | |
--region us-east1 \ | |
--platform managed \ | |
--allow-unauthenticated \ | |
--memory 4Gi \ | |
--update-secrets "NETWORK_PRIVATE_KEY=NETWORK_PRIVATE_KEY:latest,NETWORK_RPC_URL=NETWORK_RPC_URL:latest,ZKEMAIL_API_KEY=ZKEMAIL_API_KEY:latest" |