Skip to content

Latest commit

 

History

History
75 lines (48 loc) · 3.08 KB

File metadata and controls

75 lines (48 loc) · 3.08 KB

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.

  4. In order to watch the deploy see this URL.

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 - roles/run.admin: allows for the creation of new services
  • Viewer - 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 resources
  • Service Account User - roles/iam.serviceAccountUser: actAs requirement
  1. Enable the Cloud Run API and Cloud Build API..

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.

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.