This repo is created based on the following reference tutorials. The first creates a docker container for a nodejs Webserver and deploy it to Cloud Run manually in GCP. Second tutorial uses Github Actions to build and deploy a Go app into GCP. In our case, we will build and deploy a nodejs Webserver by Github Actions into GCP Cloud Run.
1) Deploy and run a container with Cloud Run on Node.js
2) Google Cloud Run with Github Actions
Under Search products and resources
search Manage resources
Create project
Or Under Menu IAM>Manage Resources
create project : gitact (choose your own project ID)
Under Console terminal >
export PROJECT_ID=gitact (project ID as above)
export ACCOUNT_NAME=gitacc (choose your own account name)
gcloud services enable cloudbuild.googleapis.com run.googleapis.com containerregistry.googleapis.com
gcloud iam service-accounts create $ACCOUNT_NAME \ --description="Cloud Run deploy account" \ --display-name="Cloud-Run-Deploy"
gcloud projects add-iam-policy-binding $PROJECT_ID \ --member=serviceAccount:$ACCOUNT_NAME@$PROJECT_ID.iam.gserviceaccount.com \ --role=roles/run.admin
gcloud projects add-iam-policy-binding $PROJECT_ID \ --member=serviceAccount:$ACCOUNT_NAME@$PROJECT_ID.iam.gserviceaccount.com \ --role=roles/storage.admin
gcloud projects add-iam-policy-binding $PROJECT_ID \ --member=serviceAccount:$ACCOUNT_NAME@$PROJECT_ID.iam.gserviceaccount.com \ --role=roles/iam.serviceAccountUser
gcloud iam service-accounts keys create key.json \ --iam-account $ACCOUNT_NAME@$PROJECT_ID.iam.gserviceaccount.com
Go to settings>secrets and enter to 4 secret values
GCP_APP_NAME=your app name (your choice of app name)
PROJECT_ID=gitact (your project name)
GCP_EMAIL = [email protected] (your client email from key.json)
GCP_CREDENTIALS = {key.json content}
Copy or clone the 4 files in this repository to your local folder:
- package.json
- index.js
- Dockerfile
- .github/workflows/GCP-Deploy.yml
- Go to your local folder
- Git add, commit and push to Github repo
You should see github actions building and deploying the webserver container to your Google Cloud run
- Go to Google cloud platform.
- Under Cloud Run
- Click on the app name
- Click on the URL to verify webserver Hello World is running
To avoid incurring charges in GCP:
- delete the app under Cloud Run thereafter
- go to home>bucket resources and delete the buckets created for the app