Skip to content

Instantly share code, notes, and snippets.

@bitclaw
Created May 27, 2024 04:34
Show Gist options
  • Save bitclaw/62371b0d34dd3cb4a7835caa3355fb5c to your computer and use it in GitHub Desktop.
Save bitclaw/62371b0d34dd3cb4a7835caa3355fb5c to your computer and use it in GitHub Desktop.
Remix Google Cloud Run
export PROJECT_ID=<your-project-id>
# e.g. europe-west1
export REGION=<your-region>
export APP_NAME=<your-app-name>
#
# Enable all required Google Cloud APIs
#
gcloud services enable artifactregistry.googleapis.com
gcloud services enable run.googleapis.com
gcloud services enable cloudbuild.googleapis.com
#
# Create a service account and bind the required roles to it
#
gcloud iam service-accounts create github-actions
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member="serviceAccount:github-actions@$PROJECT_ID.iam.gserviceaccount.com" \
--role="roles/artifactregistry.admin"
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member="serviceAccount:github-actions@$PROJECT_ID.iam.gserviceaccount.com" \
--role="roles/cloudbuild.builds.editor"
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member="serviceAccount:github-actions@$PROJECT_ID.iam.gserviceaccount.com" \
--role="roles/run.admin"
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member="serviceAccount:github-actions@$PROJECT_ID.iam.gserviceaccount.com" \
--role="roles/iam.serviceAccountUser"
gcloud projects add-iam-policy-binding $PROJECT_ID \
--member="serviceAccount:github-actions@$PROJECT_ID.iam.gserviceaccount.com" \
--role="roles/storage.admin"
#
# Create a key file so that your GitHub Action can interact with the GCP
#
gcloud iam service-accounts keys create credentials.json \
--iam-account=github-actions@$PROJECT_ID.iam.gserviceaccount.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment