* Fix readme * Update readme * Fix grammar Co-authored-by: Averi Kitsch <akitsch@google.com> |
||
|---|---|---|
| .. | ||
| .github/workflows | ||
| .dockerignore | ||
| Dockerfile | ||
| index.js | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
Cloud Build - GitHub Actions
An example workflow that uses GitHub Actions to build a Hello World Node.js app container image using Cloud Build.
This code is intended to be an example. You will likely need to change or update values to match your setup.
Workflow description
For pushes to the master branch, this workflow will:
-
Download and configure the Google Cloud SDK with the provided credentials.
-
Build, tag, and push a container 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.
-
Setup
-
Create a new Google Cloud Project (or select an existing project) and enable the Cloud Build and Cloud Build APIs.
-
Create or reuse a GitHub repository for the example workflow:
-
Move into the repository directory:
$ cd <repo> -
Copy the example into the repository:
$ cp -r <path_to>/github-actions/example-workflows/cloud-build/ .
-
Create a Google Cloud service account if one does not already exist.
-
Add the the following Cloud IAM roles to your service account:
-
Cloud Build Service Account- allows for execution of builds on your behalf -
Viewer- allows for Cloud Build log storage
-
-
Create a JSON service account key for the service account.
-
Add the following secrets to your repository's secrets:
-
RUN_PROJECT: Google Cloud project ID -
RUN_SA_EMAIL: the email of the service account -
RUN_SA_KEY: the content of the service account JSON file
-
Run the workflow
-
Add and commit your changes:
$ git add . $ git commit -m "Set up GitHub workflow" -
Push to the
masterbranch:$ git push -u origin master -
View the GitHub Actions Workflow by selecting the
Actionstab at the top of your repository on GitHub. Then click on theBuild using Cloud Buildelement to see the details.