Skip to content

Commit a048b1a

Browse files
committed
📚 Add examples of using the issue_comment event
1 parent e101392 commit a048b1a

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

terraform-apply/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,34 @@ jobs:
226226
auto_approve: true
227227
target: kubernetes_secret.tls_cert_public,kubernetes_secret.tls_cert_private
228228
```
229+
230+
### Applying a plan using a comment
231+
232+
This workflow applies a plan on demand, triggered by someone
233+
commenting `terraform apply` on the PR. The plan is taken
234+
from an existing comment generated by the [`dflook/terraform-plan`](https://github.com/dflook/terraform-github-actions/tree/master/terraform-plan)
235+
action.
236+
237+
```yaml
238+
name: Terraform Apply
239+
240+
on: [issue_comment]
241+
242+
jobs:
243+
plan:
244+
if: github.event.issue.pull_request && contains(github.event.comment.body, 'terraform apply')
245+
runs-on: ubuntu-latest
246+
name: Apply terraform plan
247+
env:
248+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
249+
steps:
250+
- name: Checkout
251+
uses: actions/checkout@v2
252+
with:
253+
ref: refs/pull/${{ github.event.issue.number }}/merge
254+
255+
- name: terraform apply
256+
uses: dflook/terraform-apply@v1
257+
with:
258+
path: my-terraform-config
259+
```

terraform-plan/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ The [dflook/terraform-apply](https://github.com/dflook/terraform-github-actions/
111111

112112
## Example usage
113113

114+
### Automatically generating a plan
115+
114116
This example workflow runs on every push to an open pull request,
115117
and create or updates a comment with the terraform plan
116118

@@ -134,3 +136,33 @@ jobs:
134136
with:
135137
path: my-terraform-config
136138
```
139+
140+
### Generating a plan using a comment
141+
142+
This workflow generates a plan on demand, triggered by someone
143+
commenting `terraform plan` on the PR. The action will create or update
144+
a comment on the PR with the generated plan.
145+
146+
```yaml
147+
name: Terraform Plan
148+
149+
on: [issue_comment]
150+
151+
jobs:
152+
plan:
153+
if: github.event.issue.pull_request && contains(github.event.comment.body, 'terraform plan')
154+
runs-on: ubuntu-latest
155+
name: Create terraform plan
156+
env:
157+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
158+
steps:
159+
- name: Checkout
160+
uses: actions/checkout@v2
161+
with:
162+
ref: refs/pull/${{ github.event.issue.number }}/merge
163+
164+
- name: terraform plan
165+
uses: dflook/terraform-plan@v1
166+
with:
167+
path: my-terraform-config
168+
```

0 commit comments

Comments
 (0)