|
40 | 40 | ${{ github.repository == 'github/docs-internal' && |
41 | 41 | !github.event.pull_request.draft && |
42 | 42 | !contains(github.event.pull_request.labels.*.name, 'reviewers-docs-engineering') && |
| 43 | + !contains(github.event.pull_request.labels.*.name, 'lockfile-churn-only') && |
43 | 44 | github.event.pull_request.head.ref != 'repo-sync' }} |
44 | 45 | runs-on: ubuntu-latest |
45 | 46 | env: |
|
50 | 51 | - name: Checkout repository |
51 | 52 | uses: actions/checkout@v6.0.1 |
52 | 53 |
|
| 54 | + # Detect PRs that only changed package-lock.json (no engineering source files). |
| 55 | + # These are usually cross-platform `npm install` churn from contributors |
| 56 | + # editing content. We comment with reset instructions instead of pulling in |
| 57 | + # docs-engineering for review. |
| 58 | + - name: Detect lockfile-only churn |
| 59 | + id: detect |
| 60 | + run: | |
| 61 | + changed=$(gh pr diff "$PR" --name-only) |
| 62 | + echo "Changed files:" |
| 63 | + echo "$changed" |
| 64 | + lockfile=$(echo "$changed" | grep -c '^package-lock\.json$' || true) |
| 65 | + other_eng=$(echo "$changed" | grep -cE '(\.tsx?$|\.scss$|^src/|^package\.json$|^\.github/|^config/|^\.devcontainer/|Dockerfile)' || true) |
| 66 | + if [ "$lockfile" -gt 0 ] && [ "$other_eng" -eq 0 ]; then |
| 67 | + echo "lockfile_only=true" >> "$GITHUB_OUTPUT" |
| 68 | + else |
| 69 | + echo "lockfile_only=false" >> "$GITHUB_OUTPUT" |
| 70 | + fi |
| 71 | +
|
| 72 | + - name: Comment and label lockfile-only PRs |
| 73 | + if: steps.detect.outputs.lockfile_only == 'true' |
| 74 | + run: | |
| 75 | + cat > /tmp/lockfile-churn-body.md <<'EOF' |
| 76 | + _Posted by Copilot on behalf of docs-engineering._ |
| 77 | +
|
| 78 | + This PR includes `package-lock.json` changes but no engineering files. Please reset the lockfile: |
| 79 | +
|
| 80 | + ``` |
| 81 | + git checkout origin/main -- package-lock.json |
| 82 | + git commit -m "Reset package-lock.json" |
| 83 | + git push |
| 84 | + ``` |
| 85 | +
|
| 86 | + If the lockfile change is intentional, remove the `lockfile-churn-only` label and request docs-engineering review. |
| 87 | + EOF |
| 88 | + gh pr comment "$PR" --body-file /tmp/lockfile-churn-body.md |
| 89 | + gh pr edit "$PR" --add-label lockfile-churn-only |
| 90 | +
|
53 | 91 | - name: Add docs engineering as a reviewer |
| 92 | + if: steps.detect.outputs.lockfile_only != 'true' |
54 | 93 | uses: ./.github/actions/retry-command |
55 | 94 | with: |
56 | 95 | command: gh pr edit $PR --add-reviewer github/docs-engineering --add-label reviewers-docs-engineering |
0 commit comments