You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 6, 2020. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+60-9Lines changed: 60 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,24 +2,75 @@
2
2
3
3
Terraform GitHub Actions allow you to run Terraform commands within GitHub Actions.
4
4
5
-
The output of the actions can be viewed from the Actions tab in the main repository view. If the actions are executed on a `pull_request` event, a comment may be posted on the pull request.
5
+
The output of the actions can be viewed from the Actions tab in the main repository view. If the actions are executed on a pull request event, a comment may be posted on the pull request.
6
6
7
7
## Success Criteria
8
8
9
9
An exit code of `0` is considered a successful execution.
10
10
11
11
## Usage
12
12
13
-
Please refer to the examples within the `examples` directory for usage.
13
+
The most common use case is to run `terraform fmt`, `terraform init`, `terraform validate`, and `terraform plan` on a pull request. A comment will be posted to the pull request depending on the output of the Terraform command being executed.
14
+
15
+
```yaml
16
+
name: 'Terraform Pull Request Workflow'
17
+
on:
18
+
- pull_request
19
+
jobs:
20
+
example:
21
+
name: 'Terraform Actions'
22
+
runs-on: ubuntu-latest
23
+
steps:
24
+
- name: 'Checkout'
25
+
uses: actions/checkout@master
26
+
- name: 'Terraform Format'
27
+
uses: hashicorp/terraform-github-actions@master
28
+
with:
29
+
tf_actions_version: 0.12.13
30
+
tf_actions_subcommand: 'fmt'
31
+
tf_actions_working_dir: '.'
32
+
tf_actions_comment: true
33
+
env:
34
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35
+
- name: 'Terraform Init'
36
+
uses: hashicorp/terraform-github-actions@master
37
+
with:
38
+
tf_actions_version: 0.12.13
39
+
tf_actions_subcommand: 'init'
40
+
tf_actions_working_dir: '.'
41
+
tf_actions_comment: true
42
+
env:
43
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44
+
- name: 'Terraform Validate'
45
+
uses: hashicorp/terraform-github-actions@master
46
+
with:
47
+
tf_actions_version: 0.12.13
48
+
tf_actions_subcommand: 'validate'
49
+
tf_actions_working_dir: '.'
50
+
tf_actions_comment: true
51
+
env:
52
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53
+
- name: 'Terraform Plan'
54
+
uses: hashicorp/terraform-github-actions@master
55
+
with:
56
+
tf_actions_version: 0.12.13
57
+
tf_actions_subcommand: 'plan'
58
+
tf_actions_working_dir: '.'
59
+
tf_actions_comment: true
60
+
env:
61
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62
+
```
63
+
64
+
This was a simplified example showing the basic features of these Terraform GitHub Actions. Please refer to the examples within the `examples` directory for more complex usage examples.
| `tf_actions_version` | `true` | | Terraform version to install and execute. |
71
+
| `tf_actions_subcommand` | `true` | | Terraform subcommand to execute. Valid values are `fmt`, `init`, `validate`, `plan`, and `apply`. |
72
+
| `tf_actions_working_dir` | `false` | `.` | The working directory to change into before executing Terraform commands. |
73
+
| `tf_actions_comment` | `false` | `true` | Whether or not to comment on pull requests. |
23
74
24
75
## Outputs
25
76
@@ -39,7 +90,7 @@ Other secrets may be needed to authenticate with Terraform backends and provider
39
90
40
91
## Environment Variables
41
92
42
-
The usual [Terraform environment variables](https://www.terraform.io/docs/commands/environment-variables.html) are supported. Here are the environments variables that might be the most beneficial.
93
+
The usual [Terraform environment variables](https://www.terraform.io/docs/commands/environment-variables.html) are supported. Here are the environment variables that might be the most beneficial.
0 commit comments