Install the Google Cloud SDK in your GitHub Actions workflow.
This action is not supported by Google Cloud.
Proudly maintained by Mathieu Bour, Vice-CTO @mathrix-education.
Since the advent of GitHub Actions, Mathrix Education SA has chosen to migrate from Google Cloud Build to this new compilation system.
If the official @actions/gcloud action works perfectly, the fact that it is in two parts (auth and cli) and that it is based on Docker makes it slow and not very suitable for launching multiple commands.
So we chose to create a JavaScript action to fix this problem, also adding additional features, such as Docker authentication with Google Cloud Container Registry.
This action currently supports only Mac-OS and Ubuntu based systems. Indeed, despite our efforts, we have not been able to launch the installation of the Google Cloud SDK on Windows.
The supported operating systems matrix is the following:
Operating system | Status |
---|---|
ubuntu-latest |
|
macos-latest |
|
windows-latest |
Name | Type | Default value |
---|---|---|
version |
'latest' / string |
'latest' |
service-account-key |
string (base64) |
'' |
project |
'auto' / 'none' / string |
'auto' |
components |
string |
'' |
configure-docker |
true / false |
false |
If you need a precise version of the Google Cloud SDK, you may provide this input. We strongly advise you to do so since using the latest version may break your workflow if Google release a breaking version.
To authenticate the SDK, you may provide a base64-encoded service account JSON key. In order to secure you workflow, use GitHub Actions secrets.
By default, if you provide a service-account-key
, the action will use it to determine which is the default project.
- If you want to specify a different project (for example, in case of cross-project interaction), you may explicitly specify your project ID here.
- If you want to disable the project configuration and provide your project ID later in your workflow, set this input
to
none
.
If you want to install additional SDK components, you may provide them in this input.
If you want to push an image to the Google Container Registry, you may authenticate the Docker agent by setting the input to true.
See action.yml for details.
- uses: mathrix-education/setup-gcloud@master
By default, the minimal example will install the latest Google Cloud SDK. Because no service account key was provided
you will have to authenticate the SDK yourself (for example, with gcloud auth activate-service-account
).
- name: Setup Google Cloud SDK
uses: mathrix-education/[email protected]
with:
service-account-key: ${{ secrets.GCLOUD_AUTH }} # base64-encoded service account JSON key
confgure-docker: true
In this example, you provide a service account key. The action automatically download the latest version of the SDK and authenticate using your key.
Then using the field "project_id"
of your key, we will set the default project using
gcloud config set project {project}
, so you do not have to do it later.
Finally, because you may want to build a Docker image and upload it to the Google Container Registry, the action will configure Docker to allow the upload of your image. Make sure that the service account has the correct rights to write on the bucket linked to the registry.