mirror of
https://github.com/EbookFoundation/free-programming-books.git
synced 2024-12-18 17:36:14 +00:00
ci(conflicts): create conflicts.yml
workflow (#7104)
* ci(conflicts): create `conflicts.yml` workflow * typo: state -> status * use section url instead of article url * Refine "comment on dirty" text Co-authored-by: ImVector <59611597+LuigiImVector@users.noreply.github.com> * fix: grammar The 'you' after 'advance' and before 'for' should not be there. Co-authored-by: Biswadeep Purkayastha <98874428+metabiswadeep@users.noreply.github.com> Co-authored-by: ImVector <59611597+LuigiImVector@users.noreply.github.com> Co-authored-by: Biswadeep Purkayastha <98874428+metabiswadeep@users.noreply.github.com>
This commit is contained in:
parent
a5b19c7d1e
commit
0e75c6d59b
71
.github/workflows/detect-conflicting-prs.yml
vendored
Normal file
71
.github/workflows/detect-conflicting-prs.yml
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
name: "Detect conflicting PRs"
|
||||
|
||||
on:
|
||||
workflow_dispatch: # manually
|
||||
# So that PRs touching the same files as the push are updated
|
||||
push:
|
||||
# So that the `dirtyLabel` is removed if conflicts are resolved
|
||||
pull_request_target: # - A pull request (even with conflicts)
|
||||
types:
|
||||
- synchronize # pushing more commits
|
||||
|
||||
permissions:
|
||||
# no checkouts/branching needed
|
||||
contents: none
|
||||
# need by "eps1lon/actions-label-merge-conflict" to manage PR label/comments
|
||||
pull-requests: write
|
||||
|
||||
# This allows a subsequently queued workflow run to interrupt/wait for previous runs
|
||||
concurrency:
|
||||
group: '${{ github.workflow }}'
|
||||
cancel-in-progress: false # true: interrupt, false = wait for
|
||||
|
||||
jobs:
|
||||
detect-prs:
|
||||
name: Detect
|
||||
if: ${{ github.actor != 'dependabot[bot]' }} # avoid dependabot PRs
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
- name: Label conflicting PRs that are open
|
||||
id: pr-labeler
|
||||
uses: eps1lon/actions-label-merge-conflict@v2.0.1
|
||||
with:
|
||||
repoToken: ${{ secrets.GITHUB_TOKEN }}
|
||||
retryAfter: 30 # seconds
|
||||
retryMax: 5 # atemps
|
||||
dirtyLabel: conflicts
|
||||
commentOnDirty: |
|
||||
Oh no 😟! Conflicts have been found.
|
||||
|
||||
Please 🙏, take a moment and [address the merge conflicts](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts) of your pull request before we can evaluate it again.
|
||||
|
||||
Thanks in advance for your effort and patience ❤️!
|
||||
continueOnMissingPermissions: true
|
||||
|
||||
- name: Print outputs
|
||||
run: echo ${{ join(steps.pr-labeler.outputs.*, ',') }}
|
||||
|
||||
- name: Set PRs outputs
|
||||
id: set-prs
|
||||
run: |
|
||||
echo "$INPUT_PRS" \
|
||||
| jq --compact-output --raw-output 'to_entries | map({number: .key, dirty: .value})' \
|
||||
| sed -e 's/^/::set-output name=prs::/'
|
||||
echo "$INPUT_PRS" \
|
||||
| jq --raw-output 'to_entries | length' \
|
||||
| sed -e 's/^/::set-output name=prs-len::/'
|
||||
env:
|
||||
INPUT_PRS: ${{ steps.pr-labeler.outputs.prDirtyStatuses }}
|
||||
|
||||
- name: Write job summary
|
||||
run: |
|
||||
echo "### Pull Request statuses" \
|
||||
>> $GITHUB_STEP_SUMMARY
|
||||
# render json array to a Markdown table with an optional "No records" message if empty
|
||||
echo "$INPUT_PRS" \
|
||||
| jq --raw-output 'map("| [#\(.number)](\(env.GITHUB_PUBLIC_URL)/\(.number)) | \(if (.dirty) then "❌" else "✔️" end) |") | join("\n") | if (. == "") then "\nNo records.\n" else "\n| PR | Mergeable? |\n|---:|:----------:|\n\(.)\n" end' \
|
||||
>> $GITHUB_STEP_SUMMARY
|
||||
env:
|
||||
GITHUB_PUBLIC_URL: ${{ format('{0}/{1}/pull', github.server_url, github.repository) }}
|
||||
INPUT_PRS: ${{ steps.set-prs.outputs.prs }}
|
Loading…
Reference in New Issue
Block a user