-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
pr_self_hosted.yaml
40 lines (32 loc) · 1.13 KB
/
pr_self_hosted.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
---
name: Trigger on pull_request (plan or apply) event with Terraform and OpenTofu on self-hosted runner.
on:
pull_request:
types: [opened, reopened, synchronize, closed]
jobs:
tf:
runs-on: self-hosted
permissions:
actions: read # Required to identify workflow run.
checks: write # Required to add status summary.
contents: read # Required to checkout repository.
pull-requests: write # Required to add comment and label.
env:
tool: terraform
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Terraform
if: env.tool == 'terraform'
uses: hashicorp/setup-terraform@v3
- name: Setup OpenTofu
if: env.tool == 'tofu'
uses: opentofu/setup-opentofu@v1
- name: Provision TF
uses: devsectop/tf-via-pr@v12
with:
command: ${{ github.event.pull_request.merged && 'apply' || 'plan' }}
arg-lock: ${{ github.event.pull_request.merged }}
working-directory: path/to/directory
plan-encrypt: ${{ secrets.PASSPHRASE }}
tool: ${{ env.tool }}