Skip to content

Commit 43ba18c

Browse files
bhimrazyCopilot
andauthored
fix(ci) : Optimize Workflow Triggers for Collaborators vs. External Contributors (#2162)
Co-authored-by: Copilot <[email protected]>
1 parent 620c749 commit 43ba18c

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

.github/workflows/cpu-tests.yml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,14 @@ jobs:
6767
python -c "$modules"
6868
6969
pytester:
70-
# skip PR trigger if secrets are not shared as for all forked PRs
70+
# Route PRs based on contributor type to avoid duplicate runs:
71+
# - Collaborators: use pull_request (tests workflow changes from PR)
72+
# - External forks: use pull_request_target (uses trusted workflow from main)
73+
# - Always run for push to main and workflow_dispatch
7174
if: |
72-
github.event_name != 'pull_request' ||
73-
(
74-
github.event_name == 'pull_request' &&
75-
contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association)
76-
)
75+
(github.event_name == 'pull_request' && contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association)) ||
76+
(github.event_name == 'pull_request_target' && !contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association)) ||
77+
(github.event_name != 'pull_request' && github.event_name != 'pull_request_target')
7778
runs-on: ${{ matrix.os }}
7879
strategy:
7980
fail-fast: false
@@ -137,11 +138,8 @@ jobs:
137138
runs-on: ubuntu-latest
138139
needs: [pytester, testing-imports]
139140
if: |
140-
github.event_name == 'pull_request_target' ||
141-
(
142-
github.event_name == 'pull_request' &&
143-
contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association)
144-
)
141+
(github.event_name == 'pull_request_target' && !contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association)) ||
142+
(github.event_name == 'pull_request' && contains('OWNER,MEMBER,COLLABORATOR', github.event.pull_request.author_association))
145143
steps:
146144
- run: echo "${{ needs.pytester.result }}"
147145
- name: failing...

0 commit comments

Comments
 (0)