Skip to content

Commit 4dddebe

Browse files
committed
update readme
1 parent 16d72c0 commit 4dddebe

File tree

4 files changed

+34
-21
lines changed

4 files changed

+34
-21
lines changed

README.md

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,29 @@ or use a tool like [Terraform](https://www.terraform.io).
1717
* Create a managed [instance group](https://cloud.google.com/compute/docs/instance-groups/). Please note that currently **only regional instance groups** are supported.
1818
* Create Service Account with Roles `Compute Admin` and `Service Account User` and export a new JSON key.
1919

20-
## Config
20+
21+
## deploy.yml
2122

2223
By default this action expects a `deploy.yml` in the root directory of the repository.
23-
Environment variables (syntax `$FOO` or `${FOO}`) used in this file are replaced automatically.
24-
[List of default variables.](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/using-environment-variables#default-environment-variables)
24+
Here is an example:
25+
26+
```yaml
27+
deploys:
28+
- name: my-app-deploy
29+
region: us-central1
30+
instance_group: my-app-instance-group
31+
instance_template_base: my-app-instance-template-base
32+
instance_template: my-app-$GITHUB_RUN_NUMBER-$GITHUB_SHA
33+
cloud_init: cloud-init.yml # see example dir
34+
labels:
35+
github-sha: $GITHUB_SHA
36+
tags:
37+
- my-tag123
38+
39+
delete_instance_templates_after: false
40+
```
41+
42+
### Config Reference
2543
2644
| Variable | Description |
2745
|--------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
@@ -35,29 +53,21 @@ Environment variables (syntax `$FOO` or `${FOO}`) used in this file are replaced
3553
| `deploys.*.startup_script` | Path to script to run when VM boots. [Read more](https://cloud.google.com/compute/docs/startupscript) |
3654
| `deploys.*.shutdown_script` | Path to script to run when VM shuts down. [Read more](https://cloud.google.com/compute/docs/shutdownscript) |
3755
| `deploys.*.cloud_init` | Path to cloud-init file. [Read more](https://cloud.google.com/container-optimized-os/docs/how-to/create-configure-instance#using_cloud-init) |
38-
| `deploys.*.vars` | A set of additional key/value variables which will be available as variables (syntax `$(FOO)`) in either startup_script, shutdown_script or cloud_init. Vars take precedence over ENV vars. |
3956
| `deploys.*.labels` | A set of key/value label pairs to assign to instances. |
4057
| `deploys.*.metadata` | A set of key/value metadata pairs to make available from within instances. |
4158
| `deploys.*.tags` | A list of tags to assign to instances. |
59+
| `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. |
4260
| `delete_instance_templates_after` | Delete old instance templates after duration, default '336h' (14 days). Set to 'false' to disable. |
4361

4462

45-
### Example deploy.yml
63+
### Variables
4664

47-
```yaml
65+
Environment variables can be used in `deploy.yml`, see example above. The syntax is `$FOO` or `${FOO}`.
4866

49-
deploys:
50-
- name: my-app-deploy
51-
region: us-central1
52-
instance_group: my-app-instance-group
53-
instance_template_base: my-app-instance-template-base
54-
instance_template: my-app-$GITHUB_RUN_NUMBER-$GITHUB_SHA
55-
cloud_init: cloud-init.yml # see example dir
56-
labels:
57-
github-sha: $GITHUB_SHA
58-
tags:
59-
- my-tag123
60-
```
67+
Environment variables or `deploys.*.vars` can be used in the `startup_script`, `shutdown_script` or `cloud_init`, see [example](example/cloud-init.yml).
68+
The syntax is `$(FOO)` to not replace actual ENV vars.
69+
70+
Github 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).
6171

6272

6373
## Github Action Inputs
@@ -68,10 +78,10 @@ deploys:
6878
| `config` | Path to config file. Default `deploy.yml` or `deploy.yaml`. |
6979

7080

71-
## Example Usage
81+
### Example Usage
7282

7383
```
74-
uses: mattes/gce-deploy-action@master
84+
uses: mattes/gce-deploy-action@v3
7585
with:
7686
creds: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
7787
config: production.yml

action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ inputs:
1414
required: false
1515
default: "deploy.yml" # or deploy.yaml
1616

17+
runs:
1718
using: "composite"
1819
steps:
1920
- name: Download gce-deploy-action

example/cloud-init.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
runcmd:
44
- iptables -w -A INPUT -p tcp --dport 8080 -j ACCEPT
55
- docker run -d --name nginx -p 8080:80 nginx
6+
- echo $(GITHUB_SHA)
7+
- echo $(string_var) $PWD
68
- sleep 600
79
- shutdown now
810

example/deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ deploys:
77
instance_template: github-action-instance-template-$GITHUB_RUN_NUMBER-${GITHUB_SHA:0:7}
88
cloud_init: cloud-init.yml
99
vars:
10-
my_script_var: "The current directory is:"
10+
string_var: "The current directory is:"
1111
labels:
1212
github_sha: $GITHUB_SHA
1313
tags:

0 commit comments

Comments
 (0)