{"id":15654560,"url":"https://github.com/mattes/gce-deploy-action","last_synced_at":"2025-05-01T04:37:22.568Z","repository":{"id":64302863,"uuid":"234668836","full_name":"mattes/gce-deploy-action","owner":"mattes","description":"Deploy to Google Cloud Compute Engine with Github Action","archived":false,"fork":false,"pushed_at":"2020-10-16T02:35:44.000Z","size":3963,"stargazers_count":30,"open_issues_count":3,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-01T04:37:12.435Z","etag":null,"topics":["ci","cloud-init","continuous-integration","deploy","deployment","github-action","google-cloud","google-cloud-compute","rolling-update","startup-script"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mattes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-18T02:10:55.000Z","updated_at":"2025-02-04T06:52:14.000Z","dependencies_parsed_at":"2023-01-15T09:45:43.348Z","dependency_job_id":null,"html_url":"https://github.com/mattes/gce-deploy-action","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattes%2Fgce-deploy-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattes%2Fgce-deploy-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattes%2Fgce-deploy-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattes%2Fgce-deploy-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mattes","download_url":"https://codeload.github.com/mattes/gce-deploy-action/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251825346,"owners_count":21649939,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ci","cloud-init","continuous-integration","deploy","deployment","github-action","google-cloud","google-cloud-compute","rolling-update","startup-script"],"created_at":"2024-10-03T12:52:27.731Z","updated_at":"2025-05-01T04:37:22.544Z","avatar_url":"https://github.com/mattes.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Deploy to Google Compute Engine\n\nGithub action to simplify deploys to Google Compute Engine. \n\nThis action will...\n\n1) Clone an existing instance template (using it as a base).\n2) Update metadata config of the newly created instance template to run a startup script.\n3) Tell the instance group manager to perform a rolling update with the new instance template.\n\n## Prerequisites\n\nSet up the following resources manually in the Cloud Console \nor use a tool like [Terraform](https://www.terraform.io).\n\n* Create a base [instance template](https://cloud.google.com/compute/docs/instance-templates/) to be cloned by this action.\n* Create a managed [instance group](https://cloud.google.com/compute/docs/instance-groups/). Please note that currently **only regional instance groups** are supported.\n* Create Service Account with Roles `Compute Admin` and `Service Account User` and export a new JSON key.\n\n\n## deploy.yml\n\nBy default this action expects a `deploy.yml` in the root directory of the repository.\nHere is an example:\n\n```yaml\ncommon:\n  labels:\n    gitsha: ${{GITHUB_SHA}}\n\ndeploys:\n  - name: my-app-deploy\n    region: us-central1\n    instance_group: my-app-instance-group\n    instance_template_base: my-app-instance-template-base\n    instance_template: my-app-${{GITHUB_RUN_NUMBER}}-${{GITHUB_SHA}}\n    cloud_init: cloud-init.yml # see example dir\n    labels: # will also have gitsha from common section\n      version: ${{APP_VERSION}}\n    tags:\n      - my-tag123\n    update_policy:\n      min_ready_sec: 30\n\ndelete_instance_templates_after: false\n```\n\n### Config Reference\n\n| Variable                                                | Description                                                                                                                                                                                                                                          |\n|---------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `deploys.*.name`                                        | ***Required*** Name of the deploy                                                                                                                                                                                                                    |\n| `deploys.*.project`                                     | Name of the Google Cloud project. Defaults to Project from Credentials.                                                                                                                                                                              |\n| `deploys.*.creds`                                       | Either a path or the contents of a Service Account JSON Key. Required, if not specified in Github action.                                                                                                                                            |\n| `deploys.*.region`                                      | ***Required*** Region of the instance group.                                                                                                                                                                                                         |\n| `deploys.*.instance_group`                              | ***Required*** Name of the instance group.                                                                                                                                                                                                           |\n| `deploys.*.instance_template_base`                      | ***Required*** Instance template to be used as base.                                                                                                                                                                                                 |\n| `deploys.*.instance_template`                           | ***Required*** Name of the newly created instance template.                                                                                                                                                                                          |\n| `deploys.*.startup_script`                              | Path or URL to script to run when VM boots. [Read more](https://cloud.google.com/compute/docs/startupscript)                                                                                                                                         |\n| `deploys.*.shutdown_script`                             | Path or URL to script to run when VM shuts down. [Read more](https://cloud.google.com/compute/docs/shutdownscript)                                                                                                                                   |\n| `deploys.*.cloud_init`                                  | Path or URL to cloud-init file. [Read more](https://cloud.google.com/container-optimized-os/docs/how-to/create-configure-instance#using_cloud-init)                                                                                                  |\n| `deploys.*.labels`                                      | A set of key/value label pairs to assign to instances. Keys override `common.*.labels`.                                                                                                                                                              |\n| `deploys.*.metadata`                                    | A set of key/value metadata pairs to make available from within instances. Keys override `common.*.metadata`.                                                                                                                                        |\n| `deploys.*.tags`                                        | A list of tags to assign to instances. Tags are merged with `common.*.tags`.                                                                                                                                                                         |\n| `deploys.*.vars`                                        | A set of additional key/value variables which will be available in either startup_script, shutdown_script or cloud_init. Keys override existing ENV vars and `common.*.vars`.                                                                        |\n| `deploys.*.update_policy.type=PROACTIVE`                | The type of update process, must be either `PROACTIVE` (default) or `OPPORTUNISTIC`. [Read more](https://cloud.google.com/compute/docs/instance-groups/rolling-out-updates-to-managed-instance-groups#starting_an_opportunistic_or_proactive_update) |\n| `deploys.*.update_policy.replacement_method=SUBSTITUTE` | What action should be used to replace instances, must be either `SUBSTITUTE` (default) or `RECREATE`. [Read more](https://cloud.google.com/compute/docs/instance-groups/rolling-out-updates-to-managed-instance-groups#replacement_method)           |\n| `deploys.*.update_policy.minimal_action=REPLACE`        | Minimal action to be taken on an instance, possible values are `NONE`, `REFRESH`, `REPLACE` (default) or `RESTART`. [Read more](https://cloud.google.com/compute/docs/instance-groups/rolling-out-updates-to-managed-instance-groups#minimal_action) |\n| `deploys.*.update_policy.min_ready_sec=10`              | Time to wait between consecutive instance updates, default is 10 seconds. [Read more](https://cloud.google.com/compute/docs/instance-groups/updating-managed-instance-groups#minimum_wait_time)                                                      |\n| `deploys.*.update_policy.max_surge=3`                   | Maximum number (or percentage, i.e. `15%`) of temporary instances to add while updating. Default is 3. [Read more](https://cloud.google.com/compute/docs/instance-groups/updating-managed-instance-groups#max_surge)                                 |\n| `deploys.*.update_policy.max_unavailable=0`             | Maximum number (or percentage, i.e. `100%`) of instances that can be offline at the same time while updating. Default is 0. [Read more](https://cloud.google.com/compute/docs/instance-groups/updating-managed-instance-groups#max_unavailable)      |\n| `common.project`                                        | Set default for `deploys.*.project`                                                                                                                                                                                                                  |\n| `common.region`                                         | Set default for `deploys.*.region`                                                                                                                                                                                                                   |\n| `common.startup_script`                                 | Set default for `deploys.*.startup_script`                                                                                                                                                                                                           |\n| `common.shutdown_script`                                | Set default for `deploys.*.shutdown_script`                                                                                                                                                                                                          |\n| `common.cloud_init`                                     | Set default for `deploys.*.cloud_init`                                                                                                                                                                                                               |\n| `common.labels`                                         | Set default for `deploys.*.labels`                                                                                                                                                                                                                   |\n| `common.metadata`                                       | Set default for `deploys.*.metadata`                                                                                                                                                                                                                 |\n| `common.tags`                                           | Set default for `deploys.*.tags`                                                                                                                                                                                                                     |\n| `common.vars`                                           | Set default for `deploys.*.vars`                                                                                                                                                                                                                     |\n| `common.update_policy.type`                             | Set default for `deploys.*.update_policy.type`                                                                                                                                                                                                       |\n| `common.update_policy.replacement_method`               | Set default for `deploys.*.update_policy.replacement_method`                                                                                                                                                                                         |\n| `common.update_policy.minimal_action`                   | Set default for `deploys.*.update_policy.minimal_action`                                                                                                                                                                                             |\n| `common.update_policy.min_ready_sec`                    | Set default for `deploys.*.update_policy.min_ready_sec`                                                                                                                                                                                              |\n| `common.update_policy.max_surge`                        | Set default for `deploys.*.update_policy.max_surge`                                                                                                                                                                                                  |\n| `common.update_policy.max_unavailable`                  | Set default for `deploys.*.update_policy.max_unavailable`                                                                                                                                                                                            |\n| `delete_instance_templates_after=336h`                  | Delete old instance templates after duration, defaults to `336h` (14 days). Set to `false` to disable.                                                                                                                                               |\n\n\n### Variables\n\nEnvironment variables can be used in `deploy.yml`, `startup_script`, `shutdown_script` and `cloud_init` files.\nThe syntax is `${{FOO}}` and supports substring extraction, i.e. `${{GITHUB_SHA:0:7}}`: \n\n```\n${{VAR:position}}        - Extracts substring from $VAR at \"position\"\n${{VAR:position:length}} - Extracts \"length\" characters of substring from $VAR at \"position\"\n```\n\nGithub sets a bunch of [default environment variables](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/using-environment-variables#default-environment-variables).\n\n\n## Github Action Usage\n\n```\nuses: mattes/gce-deploy-action@v5\nwith:\n  creds: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}\n```\n\n| Variable             | Description                                                                 |\n|----------------------|-----------------------------------------------------------------------------|\n| `creds`              | ***Required*** Either a path or the contents of a Service Account JSON Key. |\n| `config`             | Path to config file. Default `deploy.yml` or `deploy.yaml`.                 |\n\n\n\n## More Documentation\n\n* [My own Heroku in 30 mins - Deploy Rails apps to Google Cloud Compute Engine](https://gist.github.com/mattes/8f00da1f8ec55712e212f51a14745835)\n* [Managed Instance Groups](https://cloud.google.com/compute/docs/instance-groups/creating-groups-of-managed-instances)\n* [Container-Optimized OS](https://cloud.google.com/container-optimized-os/)\n* [cloud-init](https://cloud.google.com/container-optimized-os/docs/how-to/create-configure-instance#using_cloud-init)\n* [startup scripts](https://cloud.google.com/compute/docs/startupscript)\n* [Configuring an Instance](https://cloud.google.com/container-optimized-os/docs/how-to/create-configure-instance#configuring_an_instance)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattes%2Fgce-deploy-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattes%2Fgce-deploy-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattes%2Fgce-deploy-action/lists"}