| .. | ||
| .github/workflows | ||
| workflows | ||
| .dockerignore | ||
| cloud-run.yml | ||
| Dockerfile | ||
| index.js | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
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:
-
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.
Setup
-
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
- Add the following role to your Cloud Build service account,
<PROJECT_NUMBER>@cloudbuild.gserviceaccount.com:
Viewer
Run the workflow
- 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.