Skip to content

Commit 6bd8597

Browse files
committed
fix: restore pull_request_target for fork PR secrets access
The workflow was accidentally regressed to use pull_request instead of pull_request_target when PR #3 was squash merged. This prevented fork PRs from accessing repository secrets needed for the migrate app authentication. Changes: - Restore pull_request_target trigger - Add sparse checkout of REPOSITORIES.md from PR - Keep trusted scripts from main branch for security - Maintain MIGRATE_APP_ID/PRIVATE_KEY env vars from PR #28
1 parent 9de75e0 commit 6bd8597

1 file changed

Lines changed: 23 additions & 6 deletions

File tree

.github/workflows/drift-detection.yml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
name: Repository Drift Detection
22

3+
# Use pull_request_target to run trusted workflow from base repository
4+
# This allows access to secrets while running code from main branch
35
on:
4-
pull_request:
6+
pull_request_target:
57

68
jobs:
79
detect-drift:
@@ -12,8 +14,25 @@ jobs:
1214
contents: read
1315

1416
steps:
15-
- name: Checkout code
17+
# Checkout the base repository (main branch) - trusted code
18+
- name: Checkout base repository
1619
uses: actions/checkout@v4
20+
with:
21+
ref: main
22+
23+
# Checkout PR's REPOSITORIES.md to see what changes are proposed
24+
- name: Checkout PR REPOSITORIES.md
25+
uses: actions/checkout@v4
26+
with:
27+
ref: ${{ github.event.pull_request.head.sha }}
28+
sparse-checkout: |
29+
REPOSITORIES.md
30+
sparse-checkout-cone-mode: false
31+
path: pr-files
32+
33+
# Copy PR's REPOSITORIES.md to working directory
34+
- name: Use PR's REPOSITORIES.md
35+
run: cp pr-files/REPOSITORIES.md REPOSITORIES.md
1736

1837
- name: Setup Node.js
1938
uses: actions/setup-node@v4
@@ -63,8 +82,6 @@ jobs:
6382
cat sync-preview.md >> $GITHUB_STEP_SUMMARY
6483
6584
- name: Comment PR with drift report and sync preview
66-
# Skip commenting on fork PRs (no write permissions), but drift report is available in workflow summary above
67-
if: github.event.pull_request.head.repo.full_name == github.repository
6885
uses: actions/github-script@v7
6986
with:
7087
script: |
@@ -107,7 +124,7 @@ jobs:
107124
- name: Check drift detection result
108125
if: steps.drift.outputs.exit_code != '0'
109126
run: |
110-
echo "❌ Transfer blocked: worlddriven lacks admin permission on source repository"
127+
echo "❌ Transfer blocked: worlddriven-migrate app not installed on source repository"
111128
echo "Review the drift report in the workflow summary above"
112-
echo "Grant worlddriven admin access to the source repository to unblock"
129+
echo "Install the worlddriven-migrate app on the source repository to unblock"
113130
exit 1

0 commit comments

Comments
 (0)