-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
schedule_refresh.yaml
60 lines (51 loc) · 1.74 KB
/
schedule_refresh.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
---
name: Trigger on schedule (cron) event with -refresh-only to open an issue on configuration drift.
on:
schedule:
- cron: "0 */8 * * 1-5" # Every 8 hours on weekdays.
jobs:
tf:
runs-on: ubuntu-latest
permissions:
actions: read # Required to identify workflow run.
checks: write # Required to add status summary.
contents: read # Required to checkout repository.
issues: write # Required to open issue.
pull-requests: write # Required to add comment and label.
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup TF
uses: hashicorp/setup-terraform@v3
- name: Plan TF
id: provision
uses: devsectop/tf-via-pr@v12
with:
command: plan
arg-lock: false
arg-refresh-only: true
working-directory: path/to/directory
plan-encrypt: ${{ secrets.PASSPHRASE }}
- name: Open issue on drift
if: steps.provision.outputs.exitcode != 0
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff: ${{ steps.provision.outputs.diff }}
run: ${{ steps.provision.outputs.run-url }}
result: ${{ steps.provision.outputs.result }}
summary: ${{ steps.provision.outputs.summary }}
run: |
gh api /repos/{owner}/{repo}/issues \
--method POST \
--field title="Configuration drift detected" \
--field body="[View log.]($run)
<details><summary>Diff of changes.</summary>
\`\`\`diff
$diff
\`\`\`
</details>
<details><summary>$summary</summary>
\`\`\`hcl
$result
\`\`\`
</details>"