This is a GitHub Action to set up and configure the gcloud CLI.
The action offers similar functionality as the GoogleCloudPlatform/github-actions/setup-gcloud action, but differs in the following ways:
- It requires a
service-account-key
as input and always authenticates - It provides the default
project-id
as output
See action.yml.
This action requires a GCP service account key. Once created, the JSON key should be base64
encoded and added as
secret in the GitHub repository.
This example will set up gcloud
CLI and use it to authenticate docker to later build and push an image to GCR.
on: push
jobs:
staging:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: extenda/actions/setup-gcloud@v0
id: gcloud
with:
service-account-key: ${{ secrets.GCLOUD_AUTH_STAGING }}
- name: Build and push Docker image
run: |
gcloud auth configure-docker
IMAGE="gcr.io/${{ steps.gcloud.outputs.project-id }}/my-service:$GITHUB_SHA"
docker build -t $IMAGE .
docker push $IMAGE