Skip to content

Commit 60d078f

Browse files
committed
Run the CI in the correct context
1 parent 8ebcf31 commit 60d078f

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

.github/workflows/test_pr.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Test PR
22
on:
3-
pull_request: {}
3+
pull_request_target: {}
44

55
jobs:
66
test:
@@ -19,11 +19,14 @@ jobs:
1919
});
2020
2121
const packages = new Set();
22+
let bundlerChanges = false;
2223
files.forEach(file => {
2324
const match = file.filename.match(/^packages\/preview\/([^\/]+)\/([^\/]+)\//);
2425
if (match) {
2526
packages.add({ namespace: "preview", name: match[1], version: match[2] });
2627
}
28+
29+
bundlerChanges = bundlerChanges || file.filename.startsWith("bundler/");
2730
});
2831
2932
let sparseCheckoutPaths;
@@ -33,9 +36,18 @@ jobs:
3336
sparseCheckoutPaths = Array.from(packages).map((pkg) => `packages/preview/${pkg.name}/${pkg.version}/`).join('\n');
3437
}
3538
core.setOutput('sparse-checkout-paths', sparseCheckoutPaths);
36-
39+
core.setOutput('bundler-changes', bundlerChanges);
40+
- name: Debug
41+
run: |
42+
echo ${{ steps.extract-package.outputs.bundler-changes }}
43+
echo ${{ contains(github.event.pull_request.labels.*.name, 'safe-bundler-changes') }}
44+
echo '${{ toJSON(github.event.pull_request.labels) }}'
45+
- name: Require approval for bundler changes
46+
if: ${{ steps.extract-package.outputs.bundler-changes && ! contains(github.event.pull_request.labels.*.name, 'safe-bundler-changes') }}
47+
run: echo "The changes made to the bundler needs to be approved first." && false
3748
- uses: actions/checkout@v4
3849
with:
50+
ref: ${{ github.event.pull_request.head.sha }}
3951
sparse-checkout: |
4052
${{ steps.extract-package.outputs.sparse-checkout-paths }}
4153
bundler/
@@ -59,13 +71,16 @@ jobs:
5971
run: echo "base-depth=$(expr ${{ github.event.pull_request.commits }} + 1)" >> $GITHUB_OUTPUT
6072
- uses: actions/checkout@v4
6173
with:
74+
ref: ${{ github.event.pull_request.head.sha }}
6275
fetch-depth: ${{ steps.base-depth.outputs.base-depth }}
6376
- name: Fetch necessary Git objects
6477
run: |
6578
merge_sha=$(/usr/bin/git log -1 --format=%H)
6679
git fetch origin ${{ github.base_ref }}
6780
git checkout ${{ github.base_ref }}
6881
git checkout $merge_sha
82+
- name: Debug
83+
run: echo $GITHUB_REF_NAME $GITHUB_REF
6984
- uses: typst/[email protected]
7085
with:
7186
installation-id: ${{ secrets.GH_INSTALLATION_ID }}

0 commit comments

Comments
 (0)