From 99da9e123d45360e167cda3796f670057a3030fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Ord=C3=A1s?= <3125580+davorpa@users.noreply.github.com> Date: Fri, 23 Sep 2022 16:26:53 +0200 Subject: [PATCH 1/5] ci(conflicts): create `conflicts.yml` workflow --- .github/workflows/detect-conflicting-prs.yml | 71 ++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 .github/workflows/detect-conflicting-prs.yml diff --git a/.github/workflows/detect-conflicting-prs.yml b/.github/workflows/detect-conflicting-prs.yml new file mode 100644 index 0000000000000..76a8a7ab98f46 --- /dev/null +++ b/.github/workflows/detect-conflicting-prs.yml @@ -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 😟! A dirty state was reached. + + Please 🙏, take a moment and [address the merge conflicts](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-on-github) of your pull request before we can evaluate it again. + + Thanks in advance you 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 }} From 4538810a16512baff63c1b3db941ac70a438f978 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Ord=C3=A1s?= <3125580+davorpa@users.noreply.github.com> Date: Sat, 24 Sep 2022 01:02:38 +0200 Subject: [PATCH 2/5] typo: state -> status --- .github/workflows/detect-conflicting-prs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/detect-conflicting-prs.yml b/.github/workflows/detect-conflicting-prs.yml index 76a8a7ab98f46..837308801a5ee 100644 --- a/.github/workflows/detect-conflicting-prs.yml +++ b/.github/workflows/detect-conflicting-prs.yml @@ -36,7 +36,7 @@ jobs: retryMax: 5 # atemps dirtyLabel: conflicts commentOnDirty: | - Oh no 😟! A dirty state was reached. + Oh no 😟! A dirty status was reached. Please 🙏, take a moment and [address the merge conflicts](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-on-github) of your pull request before we can evaluate it again. From 0f152486540e4afb779fa8b2c57768f03a7f6ea9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Ord=C3=A1s?= <3125580+davorpa@users.noreply.github.com> Date: Sun, 25 Sep 2022 00:41:18 +0200 Subject: [PATCH 3/5] use section url instead of article url --- .github/workflows/detect-conflicting-prs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/detect-conflicting-prs.yml b/.github/workflows/detect-conflicting-prs.yml index 837308801a5ee..983e3f9535c75 100644 --- a/.github/workflows/detect-conflicting-prs.yml +++ b/.github/workflows/detect-conflicting-prs.yml @@ -38,7 +38,7 @@ jobs: commentOnDirty: | Oh no 😟! A dirty status was reached. - Please 🙏, take a moment and [address the merge conflicts](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-on-github) of your pull request before we can evaluate it again. + 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 you for your effort and patience ❤️! continueOnMissingPermissions: true From e5683a6334942a01eb5b7f8a0208fc83d8229c02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Ord=C3=A1s?= <3125580+davorpa@users.noreply.github.com> Date: Sun, 25 Sep 2022 12:20:37 +0200 Subject: [PATCH 4/5] Refine "comment on dirty" text Co-authored-by: ImVector <59611597+LuigiImVector@users.noreply.github.com> --- .github/workflows/detect-conflicting-prs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/detect-conflicting-prs.yml b/.github/workflows/detect-conflicting-prs.yml index 983e3f9535c75..baa8b19b23b60 100644 --- a/.github/workflows/detect-conflicting-prs.yml +++ b/.github/workflows/detect-conflicting-prs.yml @@ -36,7 +36,7 @@ jobs: retryMax: 5 # atemps dirtyLabel: conflicts commentOnDirty: | - Oh no 😟! A dirty status was reached. + 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. From 22fa370601b7aad8c839ab3fd2376475643e873e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Ord=C3=A1s?= <3125580+davorpa@users.noreply.github.com> Date: Wed, 5 Oct 2022 20:08:46 +0200 Subject: [PATCH 5/5] fix: grammar The 'you' after 'advance' and before 'for' should not be there. Co-authored-by: Biswadeep Purkayastha <98874428+metabiswadeep@users.noreply.github.com> --- .github/workflows/detect-conflicting-prs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/detect-conflicting-prs.yml b/.github/workflows/detect-conflicting-prs.yml index baa8b19b23b60..75a6dd3eee8a2 100644 --- a/.github/workflows/detect-conflicting-prs.yml +++ b/.github/workflows/detect-conflicting-prs.yml @@ -40,7 +40,7 @@ jobs: 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 you for your effort and patience ❤️! + Thanks in advance for your effort and patience ❤️! continueOnMissingPermissions: true - name: Print outputs