Skip to content
This repository was archived by the owner on May 6, 2020. It is now read-only.

Commit a2b6036

Browse files
authored
Updating README with example (#89)
1 parent 6862e45 commit a2b6036

File tree

1 file changed

+60
-9
lines changed

1 file changed

+60
-9
lines changed

README.md

Lines changed: 60 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,75 @@
22

33
Terraform GitHub Actions allow you to run Terraform commands within GitHub Actions.
44

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.
66

77
## Success Criteria
88

99
An exit code of `0` is considered a successful execution.
1010

1111
## Usage
1212

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.
1465

1566
## Inputs
1667

17-
| Name | Required | Default | Description |
18-
|--------------------------|----------|---------|---------------------------------------------|
19-
| `tf_actions_version` | `true` | | Terraform version to install. |
20-
| `tf_actions_subcommand` | `true` | | Terraform subcommand to execute. |
21-
| `tf_actions_working_dir` | `false` | `.` | Terraform working directory. |
22-
| `tf_actions_comment` | `false` | `true` | Whether or not to comment on pull requests. |
68+
| Name | Required | Default | Description |
69+
|--------------------------|----------|---------|---------------------------------------------------------------------------------------------------|
70+
| `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. |
2374

2475
## Outputs
2576

@@ -39,7 +90,7 @@ Other secrets may be needed to authenticate with Terraform backends and provider
3990

4091
## Environment Variables
4192

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.
4394

4495
* [`TF_LOG`](https://www.terraform.io/docs/commands/environment-variables.html#tf_log)
4596
* [`TF_VAR_name`](https://www.terraform.io/docs/commands/environment-variables.html#tf_var_name)

0 commit comments

Comments
 (0)