Skip to content

Commit a25b582

Browse files
authored
Merge pull request #444 from ranxianglei/2026-09-14_fork-pr-artifact
fix(ci): skip npm publish for fork PRs to avoid ENEEDAUTH (#413)
2 parents ebdfcd4 + 2ee1a45 commit a25b582

1 file changed

Lines changed: 23 additions & 8 deletions

File tree

.github/workflows/pr-artifact.yml

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ jobs:
2525
- run: npm run build
2626

2727
- name: Publish to npm with PR tag
28+
# Fork PRs have no access to NPM_TOKEN (secrets are withheld from
29+
# forks) — publishing would fail with ENEEDAUTH and kill the whole
30+
# job, so fork PRs skip npm but still get the tarball artifact +
31+
# comment below (#413; same fix as opencode-acp#366 / billion-context#670).
32+
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
2833
run: |
2934
PR_NUMBER="${{ github.event.pull_request.number }}"
3035
RUN_NUMBER="${{ github.run_number }}"
@@ -58,27 +63,37 @@ jobs:
5863
retention-days: 30
5964

6065
- name: Comment on PR with install instructions
66+
# Fork PRs get a read-only GITHUB_TOKEN (same withholding policy as
67+
# secrets) — issues.createComment would 403 there, so don't let that
68+
# fail the otherwise-green fork build (#413).
69+
continue-on-error: true
6170
uses: actions/github-script@v7
6271
with:
6372
script: |
6473
const prNumber = context.payload.pull_request.number;
6574
const sha = context.payload.pull_request.head.sha.slice(0, 7);
6675
const branch = context.payload.pull_request.head.ref;
6776
const runUrl = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
77+
const isFork = context.payload.pull_request.head.repo.full_name !== `${context.repo.owner}/${context.repo.repo}`;
6878
6979
const body = [
7080
'## 📦 Built Extension Artifact',
7181
'',
7282
`**Branch:** \`${branch}\` (${sha})`,
7383
'',
74-
'### Option A — Install from npm PR tag (recommended)',
75-
'',
76-
'```bash',
77-
'pi install npm:billion-context-pi@pr-' + prNumber,
78-
'```',
79-
'',
80-
'Each push to this PR publishes a new version under the `pr-' + prNumber + '` npm tag.',
81-
'',
84+
...(isFork ? [
85+
'> ℹ️ This PR comes from a fork — npm PR-tag publishing is skipped (no registry credentials). Use the artifact below.',
86+
'',
87+
] : [
88+
'### Option A — Install from npm PR tag (recommended)',
89+
'',
90+
'```bash',
91+
'pi install npm:billion-context-pi@pr-' + prNumber,
92+
'```',
93+
'',
94+
'Each push to this PR publishes a new version under the `pr-' + prNumber + '` npm tag.',
95+
'',
96+
]),
8297
'### Option B — Download artifact',
8398
'',
8499
`1. Download the artifact from the [Actions run](${runUrl})`,

0 commit comments

Comments
 (0)