|
2 | 2 |
|
3 | 3 | This is one of a suite of terraform related actions - find them at [dflook/terraform-github-actions](https://github.com/dflook/terraform-github-actions). |
4 | 4 |
|
5 | | -This actions is intially planned to manually unlock the state for the defined configuration. |
6 | | - |
7 | | -The `GITHUB_TOKEN` environment variable must be set for the PR comment to be added. |
8 | | -The action can be run on other events, which prints the plan to the workflow log. |
| 5 | +Force unlocks a Terraform remote state. |
9 | 6 |
|
10 | 7 | ## Inputs |
11 | 8 |
|
12 | 9 | * `path` |
13 | 10 |
|
14 | | - Path to the terraform root module to apply |
| 11 | + Path to the terraform root module that defines the remote state to unlock |
15 | 12 |
|
16 | 13 | - Type: string |
17 | 14 | - Optional |
18 | 15 | - Default: The action workspace |
19 | 16 |
|
20 | 17 | * `workspace` |
21 | 18 |
|
22 | | - Terraform workspace to run |
| 19 | + Terraform workspace to unlock the remote state for |
23 | 20 |
|
24 | 21 | - Type: string |
25 | 22 | - Optional |
26 | 23 | - Default: `default` |
27 | 24 |
|
28 | 25 | * `lock_id` |
29 | 26 |
|
30 | | - Lock id from the defined configuration |
| 27 | + The ID of the state lock to release |
31 | 28 |
|
32 | 29 | - Type: string |
33 | 30 | - Required |
34 | 31 |
|
35 | 32 | ## Environment Variables |
36 | 33 |
|
37 | | -* `GITHUB_TOKEN` |
38 | | - |
39 | | - The GitHub authorization token to use to create comments on a PR. |
40 | | - The token provided by GitHub Actions can be used - it can be passed by |
41 | | - using the `${{ secrets.GITHUB_TOKEN }}` expression, e.g. |
42 | | - |
43 | | - ```yaml |
44 | | - env: |
45 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
46 | | - ``` |
47 | | -
|
48 | | - The token provided by GitHub Actions will work with the default permissions. |
49 | | - The minimum permissions are `pull-requests: write`. |
50 | | - It will also likely need `contents: read` so the job can checkout the repo. |
51 | | - |
52 | | - You can also use any other App token that has `pull-requests: write` permission. |
53 | | - |
54 | | - You can use a fine-grained Personal Access Token which has repository permissions: |
55 | | - - Read access to metadata |
56 | | - - Read and Write access to pull requests |
57 | | - |
58 | | - You can also use a classic Personal Access Token which has the `repo` scope. |
59 | | - |
60 | | - The GitHub user or app that owns the token will be the PR comment author. |
61 | | - |
62 | | - - Type: string |
63 | | - - Optional |
64 | | - |
65 | | -* `TERRAFORM_ACTIONS_GITHUB_TOKEN` |
66 | | - |
67 | | - When this is set it is used instead of `GITHUB_TOKEN`, with the same behaviour. |
68 | | - The GitHub terraform provider also uses the `GITHUB_TOKEN` environment variable, |
69 | | - so this can be used to make the github actions and the terraform provider use different tokens. |
70 | | - |
71 | | - - Type: string |
72 | | - - Optional |
73 | | - |
74 | 34 | * `TERRAFORM_CLOUD_TOKENS` |
75 | 35 |
|
76 | 36 | API tokens for terraform cloud hosts, of the form `<host>=<token>`. Multiple tokens may be specified, one per line. |
@@ -133,22 +93,6 @@ The action can be run on other events, which prints the plan to the workflow log |
133 | 93 | - Type: string |
134 | 94 | - Optional |
135 | 95 |
|
136 | | -* `TF_PLAN_COLLAPSE_LENGTH` |
137 | | - |
138 | | - When PR comments are enabled, the terraform output is included in a collapsable pane. |
139 | | - |
140 | | - If a terraform plan has fewer lines than this value, the pane is expanded |
141 | | - by default when the comment is displayed. |
142 | | - |
143 | | - ```yaml |
144 | | - env: |
145 | | - TF_PLAN_COLLAPSE_LENGTH: 30 |
146 | | - ``` |
147 | | - |
148 | | - - Type: integer |
149 | | - - Optional |
150 | | - - Default: 10 |
151 | | - |
152 | 96 | * `TERRAFORM_PRE_RUN` |
153 | 97 |
|
154 | 98 | A set of commands that will be ran prior to `terraform init`. This can be used to customise the environment before running terraform. |
@@ -181,26 +125,26 @@ on: |
181 | 125 | workflow_dispatch: |
182 | 126 | inputs: |
183 | 127 | path: |
184 | | - description: "Path to the terraform files configuration" |
| 128 | + description: "Path to the terraform root module" |
185 | 129 | required: true |
186 | 130 | lock_id: |
187 | 131 | description: "Lock ID to be unlocked" |
188 | 132 | required: true |
189 | 133 |
|
| 134 | +env: |
| 135 | + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 136 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 137 | +
|
190 | 138 | jobs: |
191 | 139 | unlock: |
192 | | - name: Setup and unlock |
| 140 | + name: Unlock |
193 | 141 | runs-on: ubuntu-latest |
194 | | - env: |
195 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
196 | 142 | steps: |
197 | 143 | - name: Checkout current branch |
198 | 144 | uses: actions/checkout@v3 |
199 | | - with: |
200 | | - fetch-depth: 0 |
201 | 145 |
|
202 | 146 | - name: Terraform Unlock |
203 | | - uses: patricktalmeida/terraform-github-actions/terraform-unlock-state@add-unlock-state |
| 147 | + uses: dflook/terraform-unlock-state@v1 |
204 | 148 | with: |
205 | 149 | path: ${{ github.event.inputs.path }} |
206 | 150 | lock_id: ${{ github.event.inputs.lock_id }} |
|
0 commit comments