Skip to content

Commit 482023a

Browse files
committed
feat: Update test workflow to support running tests on forks
1 parent 7c788f9 commit 482023a

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

.github/workflows/test.yml

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ name: Tests
44
# This GitHub action runs your tests for each pull request and push.
55
# Optionally, you can turn it on using a schedule for regular testing.
66
on:
7-
pull_request:
7+
pull_request_target:
8+
types: [opened, synchronize]
89
paths-ignore:
910
- "README.md"
1011
push:
@@ -22,7 +23,21 @@ jobs:
2223
runs-on: ubuntu-latest
2324
timeout-minutes: 5
2425
steps:
26+
- id: check-access
27+
uses: actions-cool/check-user-permission@v2
28+
with:
29+
require: write
30+
username: ${{ github.triggering_actor }}
31+
- name: Check User Permission
32+
if: steps.check-access.outputs.require-result != 'false'
33+
run: |
34+
echo "User ${{ github.triggering_actor }} lacks the necessary rights on this repository."
35+
echo "Their current access level: ${{ steps.checkAccess.outputs.user-permission }}"
36+
echo "Initial trigger for this job: ${{ github.actor }}"
37+
exit 1
2538
- uses: actions/checkout@v5
39+
with:
40+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
2641
- uses: actions/setup-go@v6
2742
with:
2843
go-version-file: "go.mod"
@@ -37,7 +52,21 @@ jobs:
3752
generate:
3853
runs-on: ubuntu-latest
3954
steps:
55+
- id: check-access
56+
uses: actions-cool/check-user-permission@v2
57+
with:
58+
require: write
59+
username: ${{ github.triggering_actor }}
60+
- name: Check User Permission
61+
if: steps.check-access.outputs.require-result != 'false'
62+
run: |
63+
echo "User ${{ github.triggering_actor }} lacks the necessary rights on this repository."
64+
echo "Their current access level: ${{ steps.checkAccess.outputs.user-permission }}"
65+
echo "Initial trigger for this job: ${{ github.actor }}"
66+
exit 1
4067
- uses: actions/checkout@v5
68+
with:
69+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
4170
- uses: actions/setup-go@v6
4271
with:
4372
go-version-file: "go.mod"
@@ -65,7 +94,21 @@ jobs:
6594
terraform:
6695
- "1.13.*"
6796
steps:
97+
- id: check-access
98+
uses: actions-cool/check-user-permission@v2
99+
with:
100+
require: write
101+
username: ${{ github.triggering_actor }}
102+
- name: Check User Permission
103+
if: steps.check-access.outputs.require-result != 'false'
104+
run: |
105+
echo "User ${{ github.triggering_actor }} lacks the necessary rights on this repository."
106+
echo "Their current access level: ${{ steps.checkAccess.outputs.user-permission }}"
107+
echo "Initial trigger for this job: ${{ github.actor }}"
108+
exit 1
68109
- uses: actions/checkout@v5
110+
with:
111+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
69112
- uses: actions/setup-go@v6
70113
with:
71114
go-version-file: "go.mod"

0 commit comments

Comments
 (0)