|
1 | 1 | # Terraform GitHub Actions |
2 | | -These official Terraform GitHub Actions allow you to run `terraform fmt`, `validate`, `plan` and `apply` on your pull requests to help you review, validate and apply Terraform changes. |
3 | 2 |
|
4 | | -## Getting Started |
5 | | -To get started, check out our documentation: [https://www.terraform.io/docs/github-actions/getting-started/](https://www.terraform.io/docs/github-actions/getting-started/). |
| 3 | +Terraform GitHub Actions allow you to run Terraform commands within GitHub Actions. |
6 | 4 |
|
7 | | -## Actions |
| 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. |
8 | 6 |
|
9 | | -### Fmt Action |
10 | | -Runs `terraform fmt` and comments back if any files are not formatted correctly. |
11 | | -<img src="./assets/fmt.png" alt="Terraform Fmt Action" width="80%" /> |
| 7 | +## Success Criteria |
12 | 8 |
|
13 | | -### Validate Action |
14 | | -Runs `terraform validate` and comments back on error. |
15 | | -<img src="./assets/validate.png" alt="Terraform Validate Action" width="80%" /> |
| 9 | +An exit code of `0` is considered a successful execution. |
16 | 10 |
|
17 | | -### Plan Action |
18 | | -Runs `terraform plan` and comments back with the output. |
19 | | -<img src="./assets/plan.png" alt="Terraform Plan Action" width="80%" /> |
| 11 | +## Usage |
20 | 12 |
|
21 | | -### Apply Action |
22 | | -Runs `terraform apply` and comments back with the output. |
23 | | -<img src="./assets/apply.png" alt="Terraform Apply Action" width="80%" /> |
| 13 | +Please refer to the examples within the `examples` directory for usage. |
| 14 | + |
| 15 | +## Inputs |
| 16 | + |
| 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. | |
| 23 | + |
| 24 | +## Outputs |
| 25 | + |
| 26 | +| Name | Description | |
| 27 | +|-------------------------------|------------------------------------------------------| |
| 28 | +| `tf_actions_plan_has_changes` | Whether or not the Terraform plan contained changes. | |
| 29 | + |
| 30 | +## Secrets |
| 31 | + |
| 32 | +| Name | Description | |
| 33 | +|--------------------------|----------------------------------------------------------------------------------------------------------------------| |
| 34 | +| `GITHUB_TOKEN` | The GitHub API token used to post comments to pull requests. Not required if `tf_actions_comment` is set to `false`. | |
| 35 | + |
| 36 | +Other secrets may be needed to authenticate with Terraform backends and providers. |
| 37 | + |
| 38 | +**WARNING:** These secrets could be exposed if the action is executed on a malicious Terraform file. To avoid this, it is recommended to not use this action on public repos or repos where untrusted users can submit pull requests. |
| 39 | + |
| 40 | +## Environment Variables |
| 41 | + |
| 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. |
| 43 | + |
| 44 | +* [`TF_LOG`](https://www.terraform.io/docs/commands/environment-variables.html#tf_log) |
| 45 | +* [`TF_VAR_name`](https://www.terraform.io/docs/commands/environment-variables.html#tf_var_name) |
| 46 | +* [`TF_CLI_ARGS`](https://www.terraform.io/docs/commands/environment-variables.html#tf_cli_args-and-tf_cli_args_name) |
| 47 | +* [`TF_CLI_ARGS_name`](https://www.terraform.io/docs/commands/environment-variables.html#tf_cli_args-and-tf_cli_args_name) |
| 48 | +* `TF_WORKSPACE` |
| 49 | + |
| 50 | +Other environment variables may be configured to pass data into Terraform backends and providers. If the data is sensitive, consider using [secrets](#secrets) instead. |
0 commit comments