|
| 1 | +name: Unlabel conflicting pull requests |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: 15 3 * * * |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: read |
| 9 | + |
| 10 | +jobs: |
| 11 | + remove-label: |
| 12 | + name: Remove author ready |
| 13 | + if: github.repository == 'nodejs/node' |
| 14 | + runs-on: ubuntu-slim |
| 15 | + permissions: |
| 16 | + pull-requests: write |
| 17 | + steps: |
| 18 | + - name: Remove the label and comment |
| 19 | + env: |
| 20 | + GH_TOKEN: ${{ github.token }} |
| 21 | + MESSAGE: >- |
| 22 | + This pull request has conflicts with its base branch, removing the |
| 23 | + `author ready` label. |
| 24 | +
|
| 25 | + Please |
| 26 | + [rebase](https://github.com/nodejs/node/blob/HEAD/doc/contributing/pull-requests.md#step-5-rebase) |
| 27 | + your branch onto the latest base branch, resolve the conflicts |
| 28 | + locally, and force-push. |
| 29 | +
|
| 30 | + Afterwards the pull request needs a fresh collaborator approval, |
| 31 | + and a collaborator will add the label back once it is |
| 32 | + [author ready](https://github.com/nodejs/node/blob/HEAD/doc/contributing/collaborator-guide.md#author-ready-pull-requests) |
| 33 | + again. |
| 34 | + run: | |
| 35 | + # Requesting the mergeable field makes GitHub compute the merge state, |
| 36 | + # pull requests still reported as UNKNOWN are picked up by a later run. |
| 37 | + gh pr list \ |
| 38 | + --repo "$GITHUB_REPOSITORY" \ |
| 39 | + --label 'author ready' \ |
| 40 | + --state open \ |
| 41 | + --limit 100 \ |
| 42 | + --json number,mergeable \ |
| 43 | + --jq '.[] | select(.mergeable == "CONFLICTING") | .number' | |
| 44 | + while read -r number; do |
| 45 | + gh pr edit "$number" --repo "$GITHUB_REPOSITORY" --remove-label 'author ready' |
| 46 | + printf '%s\n' "$MESSAGE" | |
| 47 | + gh pr comment "$number" --repo "$GITHUB_REPOSITORY" --body-file - |
| 48 | + done |
0 commit comments