You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
GitHub Action
Google Cloud Compute Engine Deploy
v3.0.0
Github action to simplify deploys to Google Compute Engine.
This action will...
- Clone an existing instance template (using it as a base).
- Update metadata config of the newly created instance template to run a startup script.
- Tell the instance group manager to perform a rolling update with the new instance template.
Set up the following resources manually in the Cloud Console or use a tool like Terraform.
- Create a base instance template to be cloned by this action.
- Create a managed instance group. Please note that currently only regional instance groups are supported.
- Create Service Account with Roles
Compute Admin
andService Account User
and export a new JSON key.
By default this action expects a deploy.yml
in the root directory of the repository.
Here is an example:
deploys:
- name: my-app-deploy
region: us-central1
instance_group: my-app-instance-group
instance_template_base: my-app-instance-template-base
instance_template: my-app-$GITHUB_RUN_NUMBER-$GITHUB_SHA
cloud_init: cloud-init.yml # see example dir
labels:
github-sha: $GITHUB_SHA
tags:
- my-tag123
delete_instance_templates_after: false
Variable | Description |
---|---|
deploys.*.name |
Required Name of the deploy |
deploys.*.project |
Name of the Google Cloud project |
deploys.*.creds |
Either a path or the contents of a Service Account JSON Key. Required, if not specified in Github action. |
deploys.*.region |
Required Region of the instance group. |
deploys.*.instance_group |
Required Name of the instance group. |
deploys.*.instance_template_base |
Required Instance template to be used as base. |
deploys.*.instance_template |
Required Name of the newly created instance template. |
deploys.*.startup_script |
Path to script to run when VM boots. Read more |
deploys.*.shutdown_script |
Path to script to run when VM shuts down. Read more |
deploys.*.cloud_init |
Path to cloud-init file. Read more |
deploys.*.labels |
A set of key/value label pairs to assign to instances. |
deploys.*.metadata |
A set of key/value metadata pairs to make available from within instances. |
deploys.*.tags |
A list of tags to assign to instances. |
deploys.*.vars |
A set of additional key/value variables which will be available in either startup_script, shutdown_script or cloud_init. They take precedence over ENV vars. |
delete_instance_templates_after |
Delete old instance templates after duration, default '336h' (14 days). Set to 'false' to disable. |
Environment variables can be used in deploy.yml
, see example above. The syntax is $FOO
or ${FOO}
.
Environment variables or deploys.*.vars
can be used in the startup_script
, shutdown_script
or cloud_init
, see example.
The syntax is $(FOO)
to not replace actual ENV vars.
Github sets a bunch of default environment variables.
Variable | Description |
---|---|
creds |
Either a path or the contents of a Service Account JSON Key. |
config |
Path to config file. Default deploy.yml or deploy.yaml . |
uses: mattes/gce-deploy-action@v3
with:
creds: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
config: production.yml