Skip to content

fix(ci): PR Build Artifact publish step fails with ENEEDAUTH on fork PRs #670

Description

@ranxianglei

来源: #668 (#668) 分析 preflight 修复 PR 时发现

Problem

The PR Build Artifact workflow (.github/workflows/pr-artifact.yml) triggers on every pull_request to master, including PRs from forks. Its "Publish to npm with PR tag" step authenticates with NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}. GitHub does not pass repository secrets to workflows triggered by fork PRs, so on fork PRs the token is empty and npm publish fails with ENEEDAUTH.

Repro

  1. Open a PR to master from a fork (observed on fix(preflight): preserve complete content when recovering blocked ranges #668).
  2. The build-artifact job builds successfully, then fails at "Publish to npm with PR tag" with ENEEDAUTH (npm requires login for npm publish).

Impact

  • The PR shows a failed CI job even though the source is fine, muddying the checks signal on fork PRs.
  • All steps after the publish step are skipped: tarball creation, artifact upload, and the PR comment with install instructions — fork PR authors lose the entire artifact feature.

Suggested fix

Gate the publish step to non-fork PRs:

- name: Publish to npm with PR tag
  if: github.event.pull_request.head.repo.full_name == github.repository

and make the "Comment on PR" step drop the "Option A — Install from npm PR tag" section for fork PRs so the comment does not advertise a tag that was never published. The tarball, artifact upload, and comment steps should still run for fork PRs.

Notes

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions