Skip to content

Commit 4a4999d

Browse files
committed
v1.47.0
1 parent bb62ee1 commit 4a4999d

File tree

2 files changed

+94
-49
lines changed

2 files changed

+94
-49
lines changed

README.md

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This is one of a suite of Terraform related actions - find them at [dflook/terraform-github-actions](https://github.com/dflook/terraform-github-actions).
44

5-
:warning: This action uses the `terraform destroy` command to immediately destroy all resources in a terraform workspace.
5+
:warning: This action uses the `terraform destroy` command to immediately destroy all resources in a Terraform workspace.
66

77
To generate a plan that can be reviewed you can instead use the [dflook/terraform-plan](https://github.com/dflook/terraform-github-actions/tree/main/terraform-plan)
88
and [dflook/terraform-apply](https://github.com/dflook/terraform-github-actions/tree/main/terraform-plan) actions with the `destroy` input set to `true`.
@@ -11,23 +11,25 @@ and [dflook/terraform-apply](https://github.com/dflook/terraform-github-actions/
1111

1212
* `path`
1313

14-
Path to the Terraform root module
14+
The path to the Terraform root module directory.
1515

1616
- Type: string
1717
- Optional
1818
- Default: The action workspace
1919

2020
* `workspace`
2121

22-
Terraform workspace to destroy
22+
The name of the Terraform workspace to destroy.
2323

2424
- Type: string
2525
- Optional
2626
- Default: `default`
2727

2828
* `variables`
2929

30-
Variables to set for the terraform destroy. This should be valid Terraform syntax - like a [variable definition file](https://www.terraform.io/docs/language/values/variables.html#variable-definitions-tfvars-files).
30+
Variables to set for the terraform destroy. This should be valid Terraform syntax - like a [variable definition file](https://developer.hashicorp.com/terraform/language/values/variables#variable-definitions-tfvars-files).
31+
32+
Variables set here override any given in `var_file`s.
3133

3234
```yaml
3335
with:
@@ -39,16 +41,14 @@ and [dflook/terraform-apply](https://github.com/dflook/terraform-github-actions/
3941
]
4042
```
4143
42-
Variables set here override any given in `var_file`s.
43-
4444
- Type: string
4545
- Optional
4646
4747
* `var_file`
4848

4949
List of tfvars files to use, one per line.
5050
Paths should be relative to the GitHub Actions workspace
51-
51+
5252
```yaml
5353
with:
5454
var_file: |
@@ -61,7 +61,7 @@ and [dflook/terraform-apply](https://github.com/dflook/terraform-github-actions/
6161

6262
* `backend_config`
6363

64-
List of terraform backend config values, one per line.
64+
List of Terraform backend config values, one per line.
6565

6666
```yaml
6767
with:
@@ -90,7 +90,7 @@ and [dflook/terraform-apply](https://github.com/dflook/terraform-github-actions/
9090

9191
- Type: number
9292
- Optional
93-
- Default: The terraform default (10)
93+
- Default: The Terraform default (10).
9494

9595
## Outputs
9696

@@ -104,6 +104,8 @@ and [dflook/terraform-apply](https://github.com/dflook/terraform-github-actions/
104104
If the job fails for any other reason this will not be set.
105105
This can be used with the Actions expression syntax to conditionally run a steps.
106106

107+
- Type: string
108+
107109
* `lock-info`
108110

109111
When the job outcome is `failure` and the failure-reason is `state-locked`, this output will be set.
@@ -121,6 +123,8 @@ and [dflook/terraform-apply](https://github.com/dflook/terraform-github-actions/
121123
}
122124
```
123125

126+
- Type: string
127+
124128
## Environment Variables
125129

126130
* `GITHUB_DOT_COM_TOKEN`
@@ -156,7 +160,7 @@ and [dflook/terraform-apply](https://github.com/dflook/terraform-github-actions/
156160

157161
* `TERRAFORM_SSH_KEY`
158162

159-
A SSH private key that Terraform will use to fetch git module sources.
163+
A SSH private key that Terraform will use to fetch git/mercurial module sources.
160164

161165
This should be in PEM format.
162166

@@ -169,28 +173,6 @@ and [dflook/terraform-apply](https://github.com/dflook/terraform-github-actions/
169173
- Type: string
170174
- Optional
171175

172-
* `TERRAFORM_PRE_RUN`
173-
174-
A set of commands that will be ran prior to `terraform init`. This can be used to customise the environment before running Terraform.
175-
176-
The runtime environment for these actions is subject to change in minor version releases. If using this environment variable, specify the minor version of the action to use.
177-
178-
The runtime image is currently based on `debian:bullseye`, with the command run using `bash -xeo pipefail`.
179-
180-
For example:
181-
```yaml
182-
env:
183-
TERRAFORM_PRE_RUN: |
184-
# Install latest Azure CLI
185-
curl -skL https://aka.ms/InstallAzureCLIDeb | bash
186-
187-
# Install postgres client
188-
apt-get install -y --no-install-recommends postgresql-client
189-
```
190-
191-
- Type: string
192-
- Optional
193-
194176
* `TERRAFORM_HTTP_CREDENTIALS`
195177

196178
Credentials that will be used for fetching modules sources with `git::http://`, `git::https://`, `http://` & `https://` schemes.
@@ -216,6 +198,28 @@ and [dflook/terraform-apply](https://github.com/dflook/terraform-github-actions/
216198
- Type: string
217199
- Optional
218200

201+
* `TERRAFORM_PRE_RUN`
202+
203+
A set of commands that will be ran prior to `terraform init`. This can be used to customise the environment before running Terraform.
204+
205+
The runtime environment for these actions is subject to change in minor version releases. If using this environment variable, specify the minor version of the action to use.
206+
207+
The runtime image is currently based on `debian:bullseye`, with the command run using `bash -xeo pipefail`.
208+
209+
For example:
210+
```yaml
211+
env:
212+
TERRAFORM_PRE_RUN: |
213+
# Install latest Azure CLI
214+
curl -skL https://aka.ms/InstallAzureCLIDeb | bash
215+
216+
# Install postgres client
217+
apt-get install -y --no-install-recommends postgresql-client
218+
```
219+
220+
- Type: string
221+
- Optional
222+
219223
## Example usage
220224

221225
This example destroys the resources in a workspace named after the git branch when the associated PR is closed.

action.yaml

Lines changed: 58 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,80 @@ author: Daniel Flook
44

55
inputs:
66
path:
7-
description: Path to the Terraform configuration
7+
description: The path to the Terraform root module directory.
88
required: false
9-
default: .
9+
default: "."
1010
workspace:
11-
description: Name of the Terraform workspace
11+
description: The name of the Terraform workspace to destroy.
1212
required: false
13-
default: default
14-
backend_config:
15-
description: List of backend config values to set, one per line
16-
required: false
17-
default: ""
18-
backend_config_file:
19-
description: Path to a backend config file
20-
required: false
21-
default: ""
13+
default: "default"
2214
variables:
23-
description: Variable definitions
15+
description: |
16+
Variables to set for the terraform destroy. This should be valid Terraform syntax - like a [variable definition file](https://developer.hashicorp.com/terraform/language/values/variables#variable-definitions-tfvars-files).
17+
18+
Variables set here override any given in `var_file`s.
19+
required: false
20+
var_file:
21+
description: |
22+
List of tfvars files to use, one per line.
23+
Paths should be relative to the GitHub Actions workspace
2424
required: false
2525
var:
26-
description: Comma separated list of vars to set, e.g. 'foo=bar'
26+
description: |
27+
Comma separated list of Terraform vars to set.
28+
This is deprecated due to the following limitations:
29+
- Only primitive types can be set with `var` - number, bool and string.
30+
- String values may not contain a comma.
31+
- Values set with `var` will be overridden by values contained in `var_file`s
32+
- Does not work with the `remote` backend
33+
You can change from `var` to `variables` by putting each variable on a separate line and ensuring each string value is quoted.
2734
required: false
2835
deprecationMessage: Use the variables input instead.
29-
var_file:
30-
description: List of var file paths, one per line
36+
backend_config:
37+
description: List of Terraform backend config values, one per line.
3138
required: false
39+
default: ""
40+
backend_config_file:
41+
description: |
42+
List of Terraform backend config files to use, one per line.
43+
Paths should be relative to the GitHub Actions workspace
44+
required: false
45+
default: ""
3246
parallelism:
3347
description: Limit the number of concurrent operations
3448
required: false
3549
default: "0"
3650

51+
outputs:
52+
failure-reason:
53+
description: |
54+
When the job outcome is `failure`, this output may be set. The value may be one of:
55+
56+
- `destroy-failed` - The Terraform destroy operation failed.
57+
- `state-locked` - The Terraform state lock could not be obtained because it was already locked.
58+
59+
If the job fails for any other reason this will not be set.
60+
This can be used with the Actions expression syntax to conditionally run a steps.
61+
lock-info:
62+
description: |
63+
When the job outcome is `failure` and the failure-reason is `state-locked`, this output will be set.
64+
65+
It is a json object containing any available state lock information and typically has the form:
66+
```json
67+
{
68+
"ID": "838fbfde-c5cd-297f-84a4-d7578b4a4880",
69+
"Path": "terraform-github-actions/test-unlock-state",
70+
"Operation": "OperationTypeApply",
71+
"Who": "root@e9d43b0c6478",
72+
"Version": "1.3.7",
73+
"Created": "2023-01-28 00:16:41.560904373 +0000 UTC",
74+
"Info": ""
75+
}
76+
```
77+
3778
runs:
3879
using: docker
39-
image: docker://danielflook/terraform-github-actions@sha256:43139c747c6d59c3f83bda22afaff9e331fc959ae1e12769fe1b872ecbd8cdd4
80+
image: docker://danielflook/terraform-github-actions@sha256:7aef5fd3c9c6b005c5fe0a77b3065e5a2eeed4650993041a54c25013761237f7
4081
entrypoint: /entrypoints/destroy.sh
4182

4283
branding:

0 commit comments

Comments
 (0)