Skip to content

Commit 9f9ebf0

Browse files
authored
Merge pull request #419 from dflook/pull-request-target-harden
Harden the pull_request_target test
2 parents f8daa87 + 93bf5f9 commit 9f9ebf0

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

.github/workflows/pull_request_target.yaml

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,43 @@ name: Test pull_request_target event
33
on:
44
- pull_request_target # zizmor: ignore[dangerous-triggers]
55

6-
permissions:
7-
contents: read
6+
permissions: {}
87

98
jobs:
109
apply:
1110
runs-on: ubuntu-24.04
1211
name: Apply approved changes on pull_request_target
12+
if: github.repository == 'dflook/terraform-github-actions' && github.event.pull_request.head.repo.full_name == github.repository
1313
permissions:
14-
contents: read
1514
pull-requests: write
1615
env:
1716
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1817
steps:
19-
- name: Checkout
20-
uses: actions/checkout@v4
21-
with:
22-
persist-credentials: false
18+
- name: Create test module
19+
run: |
20+
mkdir -p test-module
21+
cat > test-module/main.tf << 'EOF'
22+
resource "random_string" "my_string" {
23+
length = 11
24+
}
25+
26+
output "output_string" {
27+
value = "the_string"
28+
}
29+
EOF
2330
2431
- name: Plan
25-
uses: ./terraform-plan
32+
uses: dflook/terraform-plan@v1
2633
with:
2734
label: pull_request_target
28-
path: tests/workflows/pull_request_target
35+
path: test-module
2936

3037
- name: Apply
31-
uses: ./terraform-apply
38+
uses: dflook/terraform-apply@v1
3239
id: output
3340
with:
3441
label: pull_request_target
35-
path: tests/workflows/pull_request_target
42+
path: test-module
3643

3744
- name: Verify outputs
3845
env:

0 commit comments

Comments
 (0)