Repo sync #1749
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Reviewers - Docs Engineering | |
| # **What it does**: Automatically add reviewers based on paths, but only for the docs-internal repo. | |
| # And sets the 'engineering' label on the PR. It also edits the PR body to add a template | |
| # for asking questions for the sake of being confident about the PRs rollout. | |
| # **Why we have it**: So we can have reviewers automatically without getting open source notifications. | |
| # **Who does it impact**: Docs team. | |
| on: | |
| pull_request: | |
| types: | |
| - edited | |
| - opened | |
| - ready_for_review | |
| - reopened | |
| - synchronize | |
| paths: | |
| - '**.ts' | |
| - '**.tsx' | |
| - '**.scss' | |
| - 'src/**' | |
| - '!src/**.json' # So that Docs Engineering isn't reviewing automated pipeline data PRs | |
| - '!src/**.yml' # So that Docs Engineering isn't reviewing automated pipeline data PRs | |
| - '!src/**.sha' # So that Docs Engineering isn't reviewing automated pipeline data PRs | |
| - '.github/**' | |
| - 'config/**' | |
| - '.devcontainer/**' | |
| - '**Dockerfile' | |
| - 'package*.json' | |
| - .github/workflows/reviewers-docs-engineering.yml | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| repository-projects: read | |
| jobs: | |
| reviewers-docs-engineering: | |
| if: >- | |
| ${{ github.repository == 'github/docs-internal' && | |
| !github.event.pull_request.draft && | |
| !contains(github.event.pull_request.labels.*.name, 'reviewers-docs-engineering') && | |
| !contains(github.event.pull_request.labels.*.name, 'lockfile-churn-only') && | |
| github.event.pull_request.head.ref != 'repo-sync' }} | |
| runs-on: ubuntu-latest | |
| env: | |
| PR: ${{ github.event.pull_request.html_url }} | |
| GH_TOKEN: ${{ secrets.DOCS_BOT_PAT_BASE }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6.0.1 | |
| # Detect PRs that only changed package-lock.json (no engineering source files). | |
| # These are usually cross-platform `npm install` churn from contributors | |
| # editing content. We comment with reset instructions instead of pulling in | |
| # docs-engineering for review. | |
| - name: Detect lockfile-only churn | |
| id: detect | |
| run: | | |
| changed=$(gh pr diff "$PR" --name-only) | |
| echo "Changed files:" | |
| echo "$changed" | |
| lockfile=$(echo "$changed" | grep -c '^package-lock\.json$' || true) | |
| other_eng=$(echo "$changed" | grep -cE '(\.tsx?$|\.scss$|^src/|^package\.json$|^\.github/|^config/|^\.devcontainer/|Dockerfile)' || true) | |
| if [ "$lockfile" -gt 0 ] && [ "$other_eng" -eq 0 ]; then | |
| echo "lockfile_only=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "lockfile_only=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Comment and label lockfile-only PRs | |
| if: steps.detect.outputs.lockfile_only == 'true' | |
| run: | | |
| cat > /tmp/lockfile-churn-body.md <<'EOF' | |
| _Posted by Copilot on behalf of docs-engineering._ | |
| This PR includes `package-lock.json` changes but no engineering files. Please reset the lockfile: | |
| ``` | |
| git checkout origin/main -- package-lock.json | |
| git commit -m "Reset package-lock.json" | |
| git push | |
| ``` | |
| If the lockfile change is intentional, remove the `lockfile-churn-only` label and request docs-engineering review. | |
| EOF | |
| gh pr comment "$PR" --body-file /tmp/lockfile-churn-body.md | |
| gh pr edit "$PR" --add-label lockfile-churn-only | |
| - name: Add docs engineering as a reviewer | |
| if: steps.detect.outputs.lockfile_only != 'true' | |
| uses: ./.github/actions/retry-command | |
| with: | |
| command: gh pr edit $PR --add-reviewer github/docs-engineering --add-label reviewers-docs-engineering |