mirror of
https://github.com/google-github-actions/setup-gcloud.git
synced 2026-08-21 14:19:24 +00:00
| .. | ||
| .github/workflows | ||
| site | ||
| deployment.yml | ||
| Dockerfile | ||
| kustomization.yml | ||
| nginx.conf | ||
| package-lock.json | ||
| README.md | ||
| service.yml | ||
Google Kubernetes Engine - GitHub Actions
An example workflow that uses GitHub Actions to deploy a static website to an existing Google Kubernetes Engine cluster.
Workflow
The example workflow will trigger on every push to this repo.
For pushes to the feature branch, the workflow will:
- Build the Docker image
- Verify the Google Cloud Platform credentials are correct
For pushes to the default branch (master), in addition to the above Actions, the workflow will:
- Tag and Push the image to Google Container Registry
- The image is available through the following tags:
latest, the branch name, and first 8 of the commit SHA gcloudserves as a credential helper for Docker. This workflow registersgcloudas a credential helper and uses the 'docker' command within thegcloudaction to push the image.
- The image is available through the following tags:
- Use a Kubernetes Deployment to push an image to the Cluster
- Note that a GKE deployment requires a unique Tag to update the pods. Using a constant tag
latestor a branch namemastermay result in successful workflows that don't update the cluster.
- Note that a GKE deployment requires a unique Tag to update the pods. Using a constant tag
Pre-reqs
- Google Cloud Platform project
- GCP Service Account with write access to GCR and GKE for this project
- GCP Service Account credentials stored as a JSON key. Base64 encode the JSON key and paste the entire blob as a secret (Repository Settings --> Secrets) named
GKE_KEY. - Also add Secrets for
GKE_PROJECTandGKE_EMAIL. Those can be found in the raw key JSON above. - An existing Kubernetes Engine cluster
- Edit
deployment.ymlto enter the correct GCR path to your image. Easy to find from GCR section of GCP console after first image push.