11name : 🧪 Run Tests
22
33on :
4+ pull_request :
5+ types : [opened, synchronize, reopened]
46 pull_request_target :
57 types : [opened, synchronize, reopened]
68 push :
@@ -18,8 +20,8 @@ permissions:
1820
1921env :
2022 # PR context helpers for conditional logic
21- IS_PR : ${{ github.event_name == 'pull_request_target' }}
22- IS_FORK : ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.repo.full_name != github.repository }}
23+ IS_PR : ${{ github.event_name == 'pull_request' || github.event_name == ' pull_request_target' }}
24+ IS_FORK : ${{ ( github.event_name == 'pull_request' || github.event_name == ' pull_request_target') && github.event.pull_request.head.repo.full_name != github.repository }}
2325 HAS_BOT_TOKEN : ${{ secrets.BOT_TOKEN != '' }}
2426
2527jobs :
3335 # Secure checkout for external PRs
3436 - uses : actions/checkout@v4
3537 with :
36- # For PRs from forks, check out the PR head to prevent token exposure
38+ # For PRs from forks via pull_request_target , check out the PR head to prevent token exposure
3739 ref : ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.ref }}
3840
3941 - uses : actions/setup-node@v4
6567 path : test-result-unit.txt
6668
6769 - name : Upload coverage to Codecov
68- if : github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == github.repository
70+ if : github.event_name == 'push' || github.event_name == 'workflow_dispatch' || (env.IS_PR == 'true' && env.IS_FORK != 'true')
6971 uses : codecov/codecov-action@v4
7072 with :
7173 token : ${{ secrets.CODECOV_TOKEN }}
@@ -123,7 +125,7 @@ jobs:
123125 # Secure checkout for external PRs
124126 - uses : actions/checkout@v4
125127 with :
126- # For PRs from forks, check out the PR head to prevent naughty people finding my token
128+ # For PRs from forks via pull_request_target , check out the PR head to prevent token exposure
127129 ref : ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.ref }}
128130
129131 - uses : actions/setup-node@v4
@@ -201,7 +203,7 @@ jobs:
201203 # Secure checkout for external PRs
202204 - uses : actions/checkout@v4
203205 with :
204- # For PRs from forks, check out the PR head to prevent token exposure
206+ # For PRs from forks via pull_request_target , check out the PR head to prevent token exposure
205207 ref : ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.ref }}
206208
207209 - uses : actions/setup-node@v4
0 commit comments