An example workflow that uses GitHub Actions to deploy a Hello World Node.js app to Cloud Run (Fully Managed).
For pushes to the default branch, master, the workflow will:
-
Verify the Google Cloud Platform credentials are correct.
-
Build, tag, and push the image to Google Container Registry.
-
The image is built using Cloud Build and pushed to Google Container Registry.
-
The image is available through the following tags:
latestand first 8 of the commit SHA.
-
-
Deploy the image to Cloud Run.
-
In order to watch the deploy see this URL.
-
Create or reuse a Github repository for the example workflow:
-
Move into your repository directory.
-
Copy the example into the repository:
cp -r <path_to>/github-actions/example-workflows/cloud-run/ ./
-
Add your Project Id to the repository's secret, named
RUN_PROJECT. -
Update
cloud-run.ymlwith the following values:
-
RUN_REGION: the region in which the resource will be deployed. -
SERVICE_NAME: your preferred name of your service and image.
Cloud Run Admin - roles/run.admin: allows for the creation of new servicesViewer - roles/viewer: allows for viewing the project (needed for Storage access)Cloud Build Service Account - roles/cloudbuild.builds.builder: allows for running and manipulating Cloud Build and Storage resourcesService Account User - roles/iam.serviceAccountUser: actAs requirement
- Enable the Cloud Run API and Cloud Build API..
- Add and commit your changes:
git add .
git commit -m "Set up Github workflow"
- Push to the
masterbranch:
git push origin master
- View the workflow by selecting the
Actionstab at the top of your repository. Then click on theBuild and Deploy to Cloud Runworkflow to see the details.
Note: If this is your first Cloud Run deployment, your image will not allow unauthenticated requests. If this is a service revision, then your service will persist the current setting. Learn more about allowing public access.