Skip to content

Commit 0e84337

Browse files
committed
use environments and pull_request_target
1 parent cebd2dc commit 0e84337

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

.github/workflows/build_test_ci.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ on:
44
push:
55
branches:
66
- main
7-
pull_request:
8-
branches:
9-
- "*"
7+
pull_request_target:
108
workflow_dispatch:
119

1210
permissions:
@@ -15,7 +13,7 @@ permissions:
1513
actions: read
1614

1715
concurrency:
18-
group: build-test-ci-${{ github.ref }}
16+
group: build-test-ci-${{ github.event.pull_request.number || github.ref_name }}
1917
cancel-in-progress: true
2018

2119
jobs:
@@ -26,6 +24,8 @@ jobs:
2624
paths: ${{ steps.filter.outputs.changes }}
2725
steps:
2826
- uses: actions/checkout@v4
27+
with:
28+
ref: ${{ github.event.pull_request.head.sha }}
2929
- name: Harden Runner
3030
uses: step-security/harden-runner@v2
3131
with:
@@ -45,6 +45,8 @@ jobs:
4545
if: ${{ contains(fromJSON(needs.changes.outputs.paths), 'src') }}
4646
steps:
4747
- uses: actions/checkout@v4
48+
with:
49+
ref: ${{ github.event.pull_request.head.sha }}
4850
- name: Validate YAML file
4951
run: yamllint templates
5052

@@ -72,6 +74,8 @@ jobs:
7274
raw.githubusercontent.com:443
7375
7476
- uses: actions/checkout@v4
77+
with:
78+
ref: ${{ github.event.pull_request.head.sha }}
7579

7680
- name: Set up Go
7781
uses: actions/setup-go@v5
@@ -99,6 +103,7 @@ jobs:
99103

100104
e2e-test:
101105
needs: changes
106+
environment: ${{ github.event.pull_request.head.repo.fork == true && 'prod-external' || 'prod' }}
102107
strategy:
103108
fail-fast: false
104109
matrix:
@@ -116,6 +121,7 @@ jobs:
116121

117122
docker-build:
118123
runs-on: ubuntu-latest
124+
environment: ${{ github.event.pull_request.head.repo.fork == true && 'prod-external' || 'prod' }}
119125
needs: changes
120126
if: ${{ contains(fromJSON(needs.changes.outputs.paths), 'src') }}
121127
steps:
@@ -140,6 +146,8 @@ jobs:
140146
storage.googleapis.com:443
141147
142148
- uses: actions/checkout@v4
149+
with:
150+
ref: ${{ github.event.pull_request.head.sha }}
143151

144152
- name: Docker cache
145153
uses: ScribeMD/[email protected]

0 commit comments

Comments
 (0)