Skip to content

Commit 75fc616

Browse files
committed
Add "safe to test" label for CI
1 parent 697bfaa commit 75fc616

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
name: CI
2+
# SECURITY NOTE: This workflow uses pull_request_target which has access to secrets.
3+
# This is needed because tests require access to external services with credentials.
4+
# `pull_request_target` will always run without manual approval, even if "Require approval for all external contributors" is enabled in the repo settings.
5+
# Therefore we implement a "safe to test" label that must be manually added once we have checked that the diff is safe.
6+
# For PRs from forks, secrets are only provided when the "safe to test" label is present.
7+
# This allows maintainers to safely test external contributions while preventing
8+
# malicious actors from accessing secrets.
29
on:
310
push:
411
branches: [main]
12+
paths-ignore:
13+
- "**.md"
14+
- ".changeset/**"
515
pull_request_target:
6-
types: [opened, synchronize, reopened]
16+
types: [opened, synchronize, reopened, labeled]
717
paths-ignore:
818
- "**.md"
919
- ".changeset/**"
@@ -14,10 +24,21 @@ on:
1424

1525
concurrency: ${{ github.workflow }}--${{ github.ref }}
1626

27+
permissions:
28+
pull-requests: write
29+
1730
jobs:
1831
main:
1932
name: Node.js 20
2033
runs-on: ubuntu-latest
34+
# Only run tests with secrets if:
35+
# 1. This is a push to main, OR
36+
# 2. PR is from the same repository (trusted), OR
37+
# 3. PR has the "safe to test" label (maintainer approved)
38+
if: |
39+
github.event_name == 'push' ||
40+
github.event.pull_request.head.repo.full_name == github.repository ||
41+
contains(github.event.pull_request.labels.*.name, 'safe to test')
2142
2243
steps:
2344
- name: Checkout sources

0 commit comments

Comments
 (0)