setup-gcloud/example-workflows/cloud-run
2020-01-14 13:09:28 -08:00
..
.github/workflows Add example 2020-01-14 13:01:56 -08:00
workflows Add example 2020-01-14 13:01:56 -08:00
.dockerignore Add example 2020-01-14 13:01:56 -08:00
cloud-run.yml Add example 2020-01-14 13:01:56 -08:00
Dockerfile Add example 2020-01-14 13:01:56 -08:00
index.js Add example 2020-01-14 13:01:56 -08:00
package-lock.json Add example 2020-01-14 13:01:56 -08:00
package.json Add example 2020-01-14 13:01:56 -08:00
README.md Add readme 2020-01-14 13:09:28 -08:00

Cloud Run - GitHub Actions

An example workflow that uses GitHub Actions to deploy a Hello World Node.js app to Cloud Run (Fully Managed).

Workflow

For pushes to the default branch, master, the workflow will:

  1. Verify the Google Cloud Platform credentials are correct.

  2. 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: latest and first 8 of the commit SHA.

  3. Deploy the image to Cloud Run.

Setup

  1. Create or reuse a Github repository for the example workflow:

  2. Create a repository.

  3. Move into your repository directory.

  4. Copy the example into the repository:

cp -r <path_to>/github-actions/example-workflows/cloud-run/ ./
  1. Add your Project Id to the repository's secret, named RUN_PROJECT.

  2. Update cloud-run.yml with the following values:

  • RUN_REGION: the region in which the resource will be deployed.

  • SERVICE_NAME: your preferred name of your service and image.

  1. Add the the following role to your service account:
  • Cloud Run Admin
  1. Add the following role to your Cloud Build service account, <PROJECT_NUMBER>@cloudbuild.gserviceaccount.com:
  • Viewer

Run the workflow

  1. Add and commit your changes:
git add .
git commit -m "Set up Github workflow"
  1. Push to the master branch:
git push origin master
  1. View the workflow by selecting the Actions tab at the top of your repository. Then click on the Build and Deploy to Cloud Run workflow to see the details.