From ea2bd49de7d72b6462fc164a795d1e65372a48fb Mon Sep 17 00:00:00 2001 From: Ashish Padhy <100484401+Shurtu-gal@users.noreply.github.com> Date: Tue, 21 Nov 2023 22:12:35 +0530 Subject: [PATCH 01/13] feat: add autoupdate-workflow --- .github/workflows/autoupdate-pr-branches.yml | 39 ++++++++++++++++++++ .github/workflows/autoupdate.yml | 34 ----------------- .github/workflows/global-replicator.yml | 2 +- 3 files changed, 40 insertions(+), 35 deletions(-) create mode 100644 .github/workflows/autoupdate-pr-branches.yml delete mode 100644 .github/workflows/autoupdate.yml diff --git a/.github/workflows/autoupdate-pr-branches.yml b/.github/workflows/autoupdate-pr-branches.yml new file mode 100644 index 00000000..7d98471b --- /dev/null +++ b/.github/workflows/autoupdate-pr-branches.yml @@ -0,0 +1,39 @@ +# This workflow is centrally managed in https://github.com/asyncapi/.github/ +# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo + +# This workflow will run on every push to the repository. And will create merge-commits for all PRs to respective branches. +# This also works with forks, not only with branches in the same repository/organization. +# Currently, does not work with forks in different organizations. + +# This workflow will be distributed to all repositories in the AsyncAPI organization. + +name: Autoupdate PR branches + +on: + push: + branches-ignore: + - 'version-bump/**' + - 'dependabot/**' + - 'bot/**' + - 'all-contributors/**' + +jobs: + autoupdate-fork: + if: startsWith(github.repository, 'asyncapi/') + runs-on: ubuntu-latest + steps: + - name: Autoupdate PR branches + uses: Shurtu-gal/autoupdate-fork-action@401ab8a7cea6c1288599f7cd030093a58c6765ee + with: + github_token: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }} + pr_filter: 'labelled' + pr_label: 'autoupdate' + merge_fail_action: 'comment' + ignore_conflicts: true + + + + + + + \ No newline at end of file diff --git a/.github/workflows/autoupdate.yml b/.github/workflows/autoupdate.yml deleted file mode 100644 index ad8e0198..00000000 --- a/.github/workflows/autoupdate.yml +++ /dev/null @@ -1,34 +0,0 @@ -# This action is centrally managed in https://github.com/asyncapi/.github/ -# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo - -# This workflow is designed to work with: -# - autoapprove and automerge workflows for dependabot and asyncapibot. -# - special release branches that we from time to time create in upstream repos. If we open up PRs for them from the very beginning of the release, the release branch will constantly update with new things from the destination branch they are opened against - -# It uses GitHub Action that auto-updates pull requests branches, whenever changes are pushed to their destination branch. -# Autoupdating to latest destination branch works only in the context of upstream repo and not forks - -name: autoupdate - -on: - push: - branches-ignore: - - 'version-bump/**' - - 'dependabot/**' - - 'bot/**' - - 'all-contributors/**' - -jobs: - autoupdate-for-bot: - if: startsWith(github.repository, 'asyncapi/') - name: Autoupdate autoapproved PR created in the upstream - runs-on: ubuntu-latest - steps: - - name: Autoupdating - uses: docker://chinthakagodawita/autoupdate-action:v1 - env: - GITHUB_TOKEN: '${{ secrets.GH_TOKEN_BOT_EVE }}' - PR_FILTER: "labelled" - PR_LABELS: "autoupdate" - PR_READY_STATE: "ready_for_review" - MERGE_CONFLICT_ACTION: "ignore" diff --git a/.github/workflows/global-replicator.yml b/.github/workflows/global-replicator.yml index 57cadda4..a747e06d 100644 --- a/.github/workflows/global-replicator.yml +++ b/.github/workflows/global-replicator.yml @@ -138,7 +138,7 @@ jobs: uses: derberg/manage-files-in-multiple-repositories@beecbe897cf5ed7f3de5a791a3f2d70102fe7c25 with: github_token: ${{ secrets.GH_TOKEN }} - patterns_to_include: .github/workflows/scripts,.github/workflows/automerge-for-humans-add-ready-to-merge-or-do-not-merge-label.yml,.github/workflows/add-good-first-issue-labels.yml,.github/workflows/automerge-for-humans-merging.yml,.github/workflows/automerge-for-humans-remove-ready-to-merge-label-on-edit.yml,.github/workflows/automerge-orphans.yml,.github/workflows/automerge.yml,.github/workflows/autoupdate.yml,.github/workflows/help-command.yml,.github/workflows/issues-prs-notifications.yml,.github/workflows/lint-pr-title.yml,.github/workflows/notify-tsc-members-mention.yml,.github/workflows/stale-issues-prs.yml,.github/workflows/welcome-first-time-contrib.yml,.github/workflows/release-announcements.yml + patterns_to_include: .github/workflows/scripts,.github/workflows/automerge-for-humans-add-ready-to-merge-or-do-not-merge-label.yml,.github/workflows/add-good-first-issue-labels.yml,.github/workflows/automerge-for-humans-merging.yml,.github/workflows/automerge-for-humans-remove-ready-to-merge-label-on-edit.yml,.github/workflows/automerge-orphans.yml,.github/workflows/automerge.yml,.github/workflows/autoupdate-pr-branches.yml,.github/workflows/help-command.yml,.github/workflows/issues-prs-notifications.yml,.github/workflows/lint-pr-title.yml,.github/workflows/notify-tsc-members-mention.yml,.github/workflows/stale-issues-prs.yml,.github/workflows/welcome-first-time-contrib.yml,.github/workflows/release-announcements.yml committer_username: asyncapi-bot committer_email: info@asyncapi.io commit_message: "ci: update of files from global .github repo" From ce809fc72b4baeea7c0eb364b31235e878278b7e Mon Sep 17 00:00:00 2001 From: Ashish Padhy <100484401+Shurtu-gal@users.noreply.github.com> Date: Tue, 21 Nov 2023 22:20:46 +0530 Subject: [PATCH 02/13] feat: add comment in events --- ...d-ready-to-merge-or-do-not-merge-label.yml | 2 +- .github/workflows/autoupdate-pr-branches.yml | 26 ++++++++++++------- .github/workflows/help-command.yml | 1 + 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/.github/workflows/automerge-for-humans-add-ready-to-merge-or-do-not-merge-label.yml b/.github/workflows/automerge-for-humans-add-ready-to-merge-or-do-not-merge-label.yml index 66606fc1..92c5d30a 100644 --- a/.github/workflows/automerge-for-humans-add-ready-to-merge-or-do-not-merge-label.yml +++ b/.github/workflows/automerge-for-humans-add-ready-to-merge-or-do-not-merge-label.yml @@ -59,7 +59,7 @@ jobs: body: `Hello, @${{ github.actor }}! 👋🏼 This PR is not up to date with the base branch and can't be merged. Please update your branch manually with the latest version of the base branch. - PRO-TIP: Add a comment to your PR with the text: \`/au\` or \`/autoupdate\` and our bot will take care of updating the branch in the future. The only requirement for this to work is to enable [Allow edits from maintainers](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork) option in your PR. + PRO-TIP: Add a comment to your PR with the text: \`/u\` or \`/update\` and our bot will take care of updating the branch in the future. The only requirement for this to work is to enable [Allow edits from maintainers](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork) option in your PR. Thanks 😄` }) } diff --git a/.github/workflows/autoupdate-pr-branches.yml b/.github/workflows/autoupdate-pr-branches.yml index 7d98471b..aba56e2d 100644 --- a/.github/workflows/autoupdate-pr-branches.yml +++ b/.github/workflows/autoupdate-pr-branches.yml @@ -17,9 +17,24 @@ on: - 'bot/**' - 'all-contributors/**' + issue_comment: + types: [created] + jobs: autoupdate-fork: - if: startsWith(github.repository, 'asyncapi/') + if: > + startsWith(github.repository, 'asyncapi/') && + ( + github.event_name == 'push' || + ( + github.event_name == 'issue_comment' && + github.event.issue.pull_request != null && + ( + contains(github.event.comment.body, '/update') || + contains(github.event.comment.body, '/u') + ) + ) + ) runs-on: ubuntu-latest steps: - name: Autoupdate PR branches @@ -29,11 +44,4 @@ jobs: pr_filter: 'labelled' pr_label: 'autoupdate' merge_fail_action: 'comment' - ignore_conflicts: true - - - - - - - \ No newline at end of file + ignore_conflicts: true \ No newline at end of file diff --git a/.github/workflows/help-command.yml b/.github/workflows/help-command.yml index d4ba4a44..c68db841 100644 --- a/.github/workflows/help-command.yml +++ b/.github/workflows/help-command.yml @@ -34,6 +34,7 @@ jobs: - \`/ready-to-merge\` or \`/rtm\` - This comment will trigger automerge of PR in case all required checks are green, approvals in place and do-not-merge label is not added - \`/do-not-merge\` or \`/dnm\` - This comment will block automerging even if all conditions are met and ready-to-merge label is added - \`/autoupdate\` or \`/au\` - This comment will add \`autoupdate\` label to the PR and keeps your PR up-to-date to the target branch's future changes. Unless there is a merge conflict or it is a draft PR.` + - \`/update\` or \`/u\` - This comment will update the PR with the latest changes from the target branch. Unless there is a merge conflict or it is a draft PR.` }) create_help_comment_issue: From fab2ed4e413447fa2cfdfefac4cca392f73785d3 Mon Sep 17 00:00:00 2001 From: Ashish Padhy <100484401+Shurtu-gal@users.noreply.github.com> Date: Tue, 21 Nov 2023 22:22:45 +0530 Subject: [PATCH 03/13] chore: update comments --- .github/workflows/autoupdate-pr-branches.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/autoupdate-pr-branches.yml b/.github/workflows/autoupdate-pr-branches.yml index aba56e2d..04119ced 100644 --- a/.github/workflows/autoupdate-pr-branches.yml +++ b/.github/workflows/autoupdate-pr-branches.yml @@ -1,7 +1,7 @@ # This workflow is centrally managed in https://github.com/asyncapi/.github/ # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo -# This workflow will run on every push to the repository. And will create merge-commits for all PRs to respective branches. +# This workflow will run on every push to the repository or comment with /update or /u. And will create merge-commits for all PRs to respective branches. # This also works with forks, not only with branches in the same repository/organization. # Currently, does not work with forks in different organizations. From 62cf4a9bcc2e970b6cc67e0d048beb83d617e505 Mon Sep 17 00:00:00 2001 From: Ashish Padhy <100484401+Shurtu-gal@users.noreply.github.com> Date: Wed, 21 Feb 2024 21:49:56 +0530 Subject: [PATCH 04/13] chore: remove unnecessary parameters --- .github/workflows/autoupdate-pr-branches.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/autoupdate-pr-branches.yml b/.github/workflows/autoupdate-pr-branches.yml index 04119ced..3314245a 100644 --- a/.github/workflows/autoupdate-pr-branches.yml +++ b/.github/workflows/autoupdate-pr-branches.yml @@ -41,7 +41,6 @@ jobs: uses: Shurtu-gal/autoupdate-fork-action@401ab8a7cea6c1288599f7cd030093a58c6765ee with: github_token: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }} - pr_filter: 'labelled' - pr_label: 'autoupdate' + pr_filter: 'all' merge_fail_action: 'comment' - ignore_conflicts: true \ No newline at end of file + ignore_conflicts: true From 9056b4342888c961e9f395225b7626cb6884952d Mon Sep 17 00:00:00 2001 From: Ashish Padhy <100484401+Shurtu-gal@users.noreply.github.com> Date: Wed, 21 Feb 2024 16:36:29 +0000 Subject: [PATCH 05/13] chore: bring the autoupdate back --- .github/workflows/autoupdate.yml | 34 +++++++++++++++++++++++++ .github/workflows/global-replicator.yml | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/autoupdate.yml diff --git a/.github/workflows/autoupdate.yml b/.github/workflows/autoupdate.yml new file mode 100644 index 00000000..afcb0736 --- /dev/null +++ b/.github/workflows/autoupdate.yml @@ -0,0 +1,34 @@ +# This action is centrally managed in https://github.com/asyncapi/.github/ +# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo + +# This workflow is designed to work with: +# - autoapprove and automerge workflows for dependabot and asyncapibot. +# - special release branches that we from time to time create in upstream repos. If we open up PRs for them from the very beginning of the release, the release branch will constantly update with new things from the destination branch they are opened against + +# It uses GitHub Action that auto-updates pull requests branches, whenever changes are pushed to their destination branch. +# Autoupdating to latest destination branch works only in the context of upstream repo and not forks + +name: autoupdate + +on: + push: + branches-ignore: + - 'version-bump/**' + - 'dependabot/**' + - 'bot/**' + - 'all-contributors/**' + +jobs: + autoupdate-for-bot: + if: startsWith(github.repository, 'asyncapi/') + name: Autoupdate autoapproved PR created in the upstream + runs-on: ubuntu-latest + steps: + - name: Autoupdating + uses: docker://chinthakagodawita/autoupdate-action:v1 + env: + GITHUB_TOKEN: '${{ secrets.GH_TOKEN_BOT_EVE }}' + PR_FILTER: "labelled" + PR_LABELS: "autoupdate" + PR_READY_STATE: "ready_for_review" + MERGE_CONFLICT_ACTION: "ignore" \ No newline at end of file diff --git a/.github/workflows/global-replicator.yml b/.github/workflows/global-replicator.yml index a747e06d..1152bf85 100644 --- a/.github/workflows/global-replicator.yml +++ b/.github/workflows/global-replicator.yml @@ -138,7 +138,7 @@ jobs: uses: derberg/manage-files-in-multiple-repositories@beecbe897cf5ed7f3de5a791a3f2d70102fe7c25 with: github_token: ${{ secrets.GH_TOKEN }} - patterns_to_include: .github/workflows/scripts,.github/workflows/automerge-for-humans-add-ready-to-merge-or-do-not-merge-label.yml,.github/workflows/add-good-first-issue-labels.yml,.github/workflows/automerge-for-humans-merging.yml,.github/workflows/automerge-for-humans-remove-ready-to-merge-label-on-edit.yml,.github/workflows/automerge-orphans.yml,.github/workflows/automerge.yml,.github/workflows/autoupdate-pr-branches.yml,.github/workflows/help-command.yml,.github/workflows/issues-prs-notifications.yml,.github/workflows/lint-pr-title.yml,.github/workflows/notify-tsc-members-mention.yml,.github/workflows/stale-issues-prs.yml,.github/workflows/welcome-first-time-contrib.yml,.github/workflows/release-announcements.yml + patterns_to_include: .github/workflows/scripts,.github/workflows/automerge-for-humans-add-ready-to-merge-or-do-not-merge-label.yml,.github/workflows/add-good-first-issue-labels.yml,.github/workflows/automerge-for-humans-merging.yml,.github/workflows/automerge-for-humans-remove-ready-to-merge-label-on-edit.yml,.github/workflows/automerge-orphans.yml,.github/workflows/automerge.yml,.github/workflows/autoupdate.yml,.github/workflows/autoupdate-pr-branches.yml,.github/workflows/help-command.yml,.github/workflows/issues-prs-notifications.yml,.github/workflows/lint-pr-title.yml,.github/workflows/notify-tsc-members-mention.yml,.github/workflows/stale-issues-prs.yml,.github/workflows/welcome-first-time-contrib.yml,.github/workflows/release-announcements.yml committer_username: asyncapi-bot committer_email: info@asyncapi.io commit_message: "ci: update of files from global .github repo" From 1e4b4818067de3076f9a16c84c0fdad058a95030 Mon Sep 17 00:00:00 2001 From: Ashish Padhy <100484401+Shurtu-gal@users.noreply.github.com> Date: Wed, 21 Feb 2024 16:38:10 +0000 Subject: [PATCH 06/13] chore: add comment --- .github/workflows/autoupdate.yml | 3 ++- .github/workflows/help-command.yml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/autoupdate.yml b/.github/workflows/autoupdate.yml index afcb0736..bcc0f01e 100644 --- a/.github/workflows/autoupdate.yml +++ b/.github/workflows/autoupdate.yml @@ -31,4 +31,5 @@ jobs: PR_FILTER: "labelled" PR_LABELS: "autoupdate" PR_READY_STATE: "ready_for_review" - MERGE_CONFLICT_ACTION: "ignore" \ No newline at end of file + MERGE_CONFLICT_ACTION: "ignore" + \ No newline at end of file diff --git a/.github/workflows/help-command.yml b/.github/workflows/help-command.yml index c68db841..303e0e16 100644 --- a/.github/workflows/help-command.yml +++ b/.github/workflows/help-command.yml @@ -33,7 +33,7 @@ jobs: - \`/ready-to-merge\` or \`/rtm\` - This comment will trigger automerge of PR in case all required checks are green, approvals in place and do-not-merge label is not added - \`/do-not-merge\` or \`/dnm\` - This comment will block automerging even if all conditions are met and ready-to-merge label is added - - \`/autoupdate\` or \`/au\` - This comment will add \`autoupdate\` label to the PR and keeps your PR up-to-date to the target branch's future changes. Unless there is a merge conflict or it is a draft PR.` + - \`/autoupdate\` or \`/au\` - This comment will add \`autoupdate\` label to the PR and keeps your PR up-to-date to the target branch's future changes. Unless there is a merge conflict or it is a draft PR. (Currently only works for upstream branches.)` - \`/update\` or \`/u\` - This comment will update the PR with the latest changes from the target branch. Unless there is a merge conflict or it is a draft PR.` }) From 9b3983c1bf7a0814140447be7075c512e34eef9d Mon Sep 17 00:00:00 2001 From: Ashish Padhy <100484401+Shurtu-gal@users.noreply.github.com> Date: Thu, 29 Feb 2024 01:06:14 +0530 Subject: [PATCH 07/13] chore: single autoupdate workflow to do everything --- .github/workflows/autoupdate-pr-branches.yml | 46 ------------------ .github/workflows/autoupdate.yml | 51 ++++++++++++-------- 2 files changed, 32 insertions(+), 65 deletions(-) delete mode 100644 .github/workflows/autoupdate-pr-branches.yml diff --git a/.github/workflows/autoupdate-pr-branches.yml b/.github/workflows/autoupdate-pr-branches.yml deleted file mode 100644 index 3314245a..00000000 --- a/.github/workflows/autoupdate-pr-branches.yml +++ /dev/null @@ -1,46 +0,0 @@ -# This workflow is centrally managed in https://github.com/asyncapi/.github/ -# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo - -# This workflow will run on every push to the repository or comment with /update or /u. And will create merge-commits for all PRs to respective branches. -# This also works with forks, not only with branches in the same repository/organization. -# Currently, does not work with forks in different organizations. - -# This workflow will be distributed to all repositories in the AsyncAPI organization. - -name: Autoupdate PR branches - -on: - push: - branches-ignore: - - 'version-bump/**' - - 'dependabot/**' - - 'bot/**' - - 'all-contributors/**' - - issue_comment: - types: [created] - -jobs: - autoupdate-fork: - if: > - startsWith(github.repository, 'asyncapi/') && - ( - github.event_name == 'push' || - ( - github.event_name == 'issue_comment' && - github.event.issue.pull_request != null && - ( - contains(github.event.comment.body, '/update') || - contains(github.event.comment.body, '/u') - ) - ) - ) - runs-on: ubuntu-latest - steps: - - name: Autoupdate PR branches - uses: Shurtu-gal/autoupdate-fork-action@401ab8a7cea6c1288599f7cd030093a58c6765ee - with: - github_token: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }} - pr_filter: 'all' - merge_fail_action: 'comment' - ignore_conflicts: true diff --git a/.github/workflows/autoupdate.yml b/.github/workflows/autoupdate.yml index bcc0f01e..9339423c 100644 --- a/.github/workflows/autoupdate.yml +++ b/.github/workflows/autoupdate.yml @@ -1,14 +1,13 @@ -# This action is centrally managed in https://github.com/asyncapi/.github/ +# This workflow is centrally managed in https://github.com/asyncapi/.github/ # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo -# This workflow is designed to work with: -# - autoapprove and automerge workflows for dependabot and asyncapibot. -# - special release branches that we from time to time create in upstream repos. If we open up PRs for them from the very beginning of the release, the release branch will constantly update with new things from the destination branch they are opened against +# This workflow will run on every push to the repository or comment with /update or /u. And will create merge-commits for all PRs to respective branches. +# This also works with forks, not only with branches in the same repository/organization. +# Currently, does not work with forks in different organizations. -# It uses GitHub Action that auto-updates pull requests branches, whenever changes are pushed to their destination branch. -# Autoupdating to latest destination branch works only in the context of upstream repo and not forks +# This workflow will be distributed to all repositories in the AsyncAPI organization. -name: autoupdate +name: Autoupdate PR branches on: push: @@ -18,18 +17,32 @@ on: - 'bot/**' - 'all-contributors/**' + issue_comment: + types: [created] + jobs: - autoupdate-for-bot: - if: startsWith(github.repository, 'asyncapi/') - name: Autoupdate autoapproved PR created in the upstream + autoupdate-fork: + if: > + startsWith(github.repository, 'asyncapi/') && + ( + github.event_name == 'push' || + ( + github.event_name == 'issue_comment' && + github.event.issue.pull_request != null && + ( + contains(github.event.comment.body, '/update') || + contains(github.event.comment.body, '/u') + ) + ) + ) runs-on: ubuntu-latest steps: - - name: Autoupdating - uses: docker://chinthakagodawita/autoupdate-action:v1 - env: - GITHUB_TOKEN: '${{ secrets.GH_TOKEN_BOT_EVE }}' - PR_FILTER: "labelled" - PR_LABELS: "autoupdate" - PR_READY_STATE: "ready_for_review" - MERGE_CONFLICT_ACTION: "ignore" - \ No newline at end of file + - name: Autoupdate PR branches + uses: Shurtu-gal/autoupdate-fork-action@a5019320a0462993ded9bbe6c04fb1c6684d67c7 + with: + github_token: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }} + # The label to see on push event. By default, on issue_comment event there will be no PR_FILTER + pr_filter: 'labelled' + pr_label: 'autoupdate' + merge_fail_action: 'comment' + ignore_conflicts: true From 84ded3669be301463c2a98a47d1f26eb5b1e07e1 Mon Sep 17 00:00:00 2001 From: Ashish Padhy <100484401+Shurtu-gal@users.noreply.github.com> Date: Mon, 11 Mar 2024 21:40:25 +0530 Subject: [PATCH 08/13] chore: update commit ref --- .github/workflows/autoupdate.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/autoupdate.yml b/.github/workflows/autoupdate.yml index 9339423c..4d70d0d9 100644 --- a/.github/workflows/autoupdate.yml +++ b/.github/workflows/autoupdate.yml @@ -38,7 +38,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Autoupdate PR branches - uses: Shurtu-gal/autoupdate-fork-action@a5019320a0462993ded9bbe6c04fb1c6684d67c7 + uses: Shurtu-gal/autoupdate-fork-action@2fdcd58a50e41c187e56160d05c128b00c664164 with: github_token: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }} # The label to see on push event. By default, on issue_comment event there will be no PR_FILTER From 54817940b0351da2fef48205b4231314def2b73a Mon Sep 17 00:00:00 2001 From: Ashish Padhy <100484401+Shurtu-gal@users.noreply.github.com> Date: Mon, 11 Mar 2024 22:25:47 +0530 Subject: [PATCH 09/13] chore: apply suggestions Co-authored-by: Lukasz Gornicki --- ...ge-for-humans-add-ready-to-merge-or-do-not-merge-label.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/automerge-for-humans-add-ready-to-merge-or-do-not-merge-label.yml b/.github/workflows/automerge-for-humans-add-ready-to-merge-or-do-not-merge-label.yml index 92c5d30a..02d71a79 100644 --- a/.github/workflows/automerge-for-humans-add-ready-to-merge-or-do-not-merge-label.yml +++ b/.github/workflows/automerge-for-humans-add-ready-to-merge-or-do-not-merge-label.yml @@ -59,7 +59,9 @@ jobs: body: `Hello, @${{ github.actor }}! 👋🏼 This PR is not up to date with the base branch and can't be merged. Please update your branch manually with the latest version of the base branch. - PRO-TIP: Add a comment to your PR with the text: \`/u\` or \`/update\` and our bot will take care of updating the branch in the future. The only requirement for this to work is to enable [Allow edits from maintainers](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork) option in your PR. + PRO-TIP: To request an update from the upstream branch, simply comment \`/u\` or \`/update\` and our bot will handle the update operation promptly. + + The only requirement for this to work is to enable [Allow edits from maintainers](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork) option in your PR. Also the update will not work if your fork is located in an organization, not under your personal profile. Thanks 😄` }) } From a80e1e5cc7f29cbf30af42aed2618730aaa71047 Mon Sep 17 00:00:00 2001 From: Ashish Padhy <100484401+Shurtu-gal@users.noreply.github.com> Date: Thu, 28 Mar 2024 15:35:36 +0530 Subject: [PATCH 10/13] feat: change action to github-script --- .github/workflows/autoupdate-fork.yml | 99 +++++++++++++++++++++++++ .github/workflows/autoupdate.yml | 50 +++++-------- .github/workflows/global-replicator.yml | 2 +- 3 files changed, 118 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/autoupdate-fork.yml diff --git a/.github/workflows/autoupdate-fork.yml b/.github/workflows/autoupdate-fork.yml new file mode 100644 index 00000000..f06bb8fd --- /dev/null +++ b/.github/workflows/autoupdate-fork.yml @@ -0,0 +1,99 @@ +# This workflow is centrally managed in https://github.com/asyncapi/.github/ +# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo + +# This workflow will run on every comment with /update or /u. And will create merge-commits for the PR. +# This also works with forks, not only with branches in the same repository/organization. +# Currently, does not work with forks in different organizations. + +# This workflow will be distributed to all repositories in the AsyncAPI organization + +name: Autoupdate PR branches from fork + +on: + issue_comment: + types: [created] + +jobs: + autoupdate-pr: + if: > + startsWith(github.repository, 'asyncapi/') && + github.event_name == 'issue_comment' && ( + contains(github.event.comment.body, '/update') || + contains(github.event.comment.body, '/u') + ) + runs-on: ubuntu-latest + steps: + - name: Get Pull Request Details + id: pr + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }} + previews: 'merge-info-preview' # https://docs.github.com/en/graphql/overview/schema-previews#merge-info-preview-more-detailed-information-about-a-pull-requests-merge-state-preview + script: | + const prNumber = context.payload.issue.number; + core.debug(`PR Number: ${prNumber}`); + const { data: pr } = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: prNumber + }); + + // If the PR has conflicts, we don't want to update it + const updateable = ['behind', 'blocked', 'unknown', 'draft', 'clean'].includes(pr.mergeable_state); + console.log(`PR #${prNumber} is ${pr.mergeable_state} and is ${updateable ? 'updateable' : 'not updateable'}`); + core.setOutput('updateable', updateable); + + core.debug(`Updating PR #${prNumber} with head ${pr.head.sha}`); + + return { + id: pr.node_id, + number: prNumber, + head: pr.head.sha, + } + - name: Update the Pull Request + if: steps.pr.outputs.updateable == 'true' + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }} + script: | + const mutation = `mutation update($input: UpdatePullRequestBranchInput!) { + updatePullRequestBranch(input: $input) { + pullRequest { + mergeable + } + } + }`; + + const pr_details = ${{ steps.pr.outputs.result }}; + + try { + const { data } = await github.graphql(mutation, { + input: { + pullRequestId: pr_details.id, + expectedHeadOid: pr_details.head, + } + }); + } catch (GraphQLError) { + core.debug(GraphQLError); + if ( + GraphQLError.name === 'GraphqlResponseError' && + GraphQLError.errors.some( + error => error.type === 'FORBIDDEN' || error.type === 'UNAUTHORIZED' + ) + ) { + // Add comment to PR if the bot doesn't have permissions to update the PR + + const comment = `@${context.actor} I don't have permissions to update this PR. Please ask the PR author to check the "Allow edits from maintainers" checkbox in the PR settings.`; + + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body: comment + }); + + core.setFailed('Bot does not have permissions to update the PR'); + } else { + core.setFailed(GraphQLError.message); + } + } \ No newline at end of file diff --git a/.github/workflows/autoupdate.yml b/.github/workflows/autoupdate.yml index 9339423c..afcb0736 100644 --- a/.github/workflows/autoupdate.yml +++ b/.github/workflows/autoupdate.yml @@ -1,13 +1,14 @@ -# This workflow is centrally managed in https://github.com/asyncapi/.github/ +# This action is centrally managed in https://github.com/asyncapi/.github/ # Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo -# This workflow will run on every push to the repository or comment with /update or /u. And will create merge-commits for all PRs to respective branches. -# This also works with forks, not only with branches in the same repository/organization. -# Currently, does not work with forks in different organizations. +# This workflow is designed to work with: +# - autoapprove and automerge workflows for dependabot and asyncapibot. +# - special release branches that we from time to time create in upstream repos. If we open up PRs for them from the very beginning of the release, the release branch will constantly update with new things from the destination branch they are opened against -# This workflow will be distributed to all repositories in the AsyncAPI organization. +# It uses GitHub Action that auto-updates pull requests branches, whenever changes are pushed to their destination branch. +# Autoupdating to latest destination branch works only in the context of upstream repo and not forks -name: Autoupdate PR branches +name: autoupdate on: push: @@ -17,32 +18,17 @@ on: - 'bot/**' - 'all-contributors/**' - issue_comment: - types: [created] - jobs: - autoupdate-fork: - if: > - startsWith(github.repository, 'asyncapi/') && - ( - github.event_name == 'push' || - ( - github.event_name == 'issue_comment' && - github.event.issue.pull_request != null && - ( - contains(github.event.comment.body, '/update') || - contains(github.event.comment.body, '/u') - ) - ) - ) + autoupdate-for-bot: + if: startsWith(github.repository, 'asyncapi/') + name: Autoupdate autoapproved PR created in the upstream runs-on: ubuntu-latest steps: - - name: Autoupdate PR branches - uses: Shurtu-gal/autoupdate-fork-action@a5019320a0462993ded9bbe6c04fb1c6684d67c7 - with: - github_token: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }} - # The label to see on push event. By default, on issue_comment event there will be no PR_FILTER - pr_filter: 'labelled' - pr_label: 'autoupdate' - merge_fail_action: 'comment' - ignore_conflicts: true + - name: Autoupdating + uses: docker://chinthakagodawita/autoupdate-action:v1 + env: + GITHUB_TOKEN: '${{ secrets.GH_TOKEN_BOT_EVE }}' + PR_FILTER: "labelled" + PR_LABELS: "autoupdate" + PR_READY_STATE: "ready_for_review" + MERGE_CONFLICT_ACTION: "ignore" \ No newline at end of file diff --git a/.github/workflows/global-replicator.yml b/.github/workflows/global-replicator.yml index 1152bf85..f6f9b2ac 100644 --- a/.github/workflows/global-replicator.yml +++ b/.github/workflows/global-replicator.yml @@ -138,7 +138,7 @@ jobs: uses: derberg/manage-files-in-multiple-repositories@beecbe897cf5ed7f3de5a791a3f2d70102fe7c25 with: github_token: ${{ secrets.GH_TOKEN }} - patterns_to_include: .github/workflows/scripts,.github/workflows/automerge-for-humans-add-ready-to-merge-or-do-not-merge-label.yml,.github/workflows/add-good-first-issue-labels.yml,.github/workflows/automerge-for-humans-merging.yml,.github/workflows/automerge-for-humans-remove-ready-to-merge-label-on-edit.yml,.github/workflows/automerge-orphans.yml,.github/workflows/automerge.yml,.github/workflows/autoupdate.yml,.github/workflows/autoupdate-pr-branches.yml,.github/workflows/help-command.yml,.github/workflows/issues-prs-notifications.yml,.github/workflows/lint-pr-title.yml,.github/workflows/notify-tsc-members-mention.yml,.github/workflows/stale-issues-prs.yml,.github/workflows/welcome-first-time-contrib.yml,.github/workflows/release-announcements.yml + patterns_to_include: .github/workflows/scripts,.github/workflows/automerge-for-humans-add-ready-to-merge-or-do-not-merge-label.yml,.github/workflows/add-good-first-issue-labels.yml,.github/workflows/automerge-for-humans-merging.yml,.github/workflows/automerge-for-humans-remove-ready-to-merge-label-on-edit.yml,.github/workflows/automerge-orphans.yml,.github/workflows/automerge.yml,.github/workflows/autoupdate.yml,.github/workflows/autoupdate-fork.yml,.github/workflows/help-command.yml,.github/workflows/issues-prs-notifications.yml,.github/workflows/lint-pr-title.yml,.github/workflows/notify-tsc-members-mention.yml,.github/workflows/stale-issues-prs.yml,.github/workflows/welcome-first-time-contrib.yml,.github/workflows/release-announcements.yml committer_username: asyncapi-bot committer_email: info@asyncapi.io commit_message: "ci: update of files from global .github repo" From 3a30b5e938f239eab8dd3d321ed5cd0127d20704 Mon Sep 17 00:00:00 2001 From: Ashish Padhy <100484401+Shurtu-gal@users.noreply.github.com> Date: Wed, 3 Apr 2024 14:50:59 +0530 Subject: [PATCH 11/13] chore: change the comment messages --- .github/workflows/autoupdate-fork.yml | 6 +++--- .github/workflows/help-command.yml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/autoupdate-fork.yml b/.github/workflows/autoupdate-fork.yml index f06bb8fd..745eac26 100644 --- a/.github/workflows/autoupdate-fork.yml +++ b/.github/workflows/autoupdate-fork.yml @@ -17,7 +17,8 @@ jobs: autoupdate-pr: if: > startsWith(github.repository, 'asyncapi/') && - github.event_name == 'issue_comment' && ( + github.event.issue.pull_request && + github.event.issue.state != 'closed' && ( contains(github.event.comment.body, '/update') || contains(github.event.comment.body, '/u') ) @@ -83,8 +84,7 @@ jobs: ) { // Add comment to PR if the bot doesn't have permissions to update the PR - const comment = `@${context.actor} I don't have permissions to update this PR. Please ask the PR author to check the "Allow edits from maintainers" checkbox in the PR settings.`; - + const comment = `@${context.actor} I don't have permissions to update this PR. Please ask the PR author to check the "Allow edits from maintainers" checkbox in the PR settings. Another possible reason for failure can due to the fork being in an organisation and not under a user.`; await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, diff --git a/.github/workflows/help-command.yml b/.github/workflows/help-command.yml index 303e0e16..8aac8747 100644 --- a/.github/workflows/help-command.yml +++ b/.github/workflows/help-command.yml @@ -33,8 +33,8 @@ jobs: - \`/ready-to-merge\` or \`/rtm\` - This comment will trigger automerge of PR in case all required checks are green, approvals in place and do-not-merge label is not added - \`/do-not-merge\` or \`/dnm\` - This comment will block automerging even if all conditions are met and ready-to-merge label is added - - \`/autoupdate\` or \`/au\` - This comment will add \`autoupdate\` label to the PR and keeps your PR up-to-date to the target branch's future changes. Unless there is a merge conflict or it is a draft PR. (Currently only works for upstream branches.)` - - \`/update\` or \`/u\` - This comment will update the PR with the latest changes from the target branch. Unless there is a merge conflict or it is a draft PR.` + - \`/autoupdate\` or \`/au\` - This comment will add \`autoupdate\` label to the PR and keeps your PR up-to-date to the target branch's future changes. Unless there is a merge conflict or it is a draft PR. (Currently only works for upstream branches.) + - \`/update\` or \`/u\` - This comment will update the PR with the latest changes from the target branch. Unless there is a merge conflict or it is a draft PR. NOTE: this only updates the PR once, so if you need to update again, you need to call the command again.` }) create_help_comment_issue: From 1174b2a0a32005e2682d93f378926ace670cce8c Mon Sep 17 00:00:00 2001 From: Ashish Padhy <100484401+Shurtu-gal@users.noreply.github.com> Date: Thu, 4 Apr 2024 19:13:43 +0530 Subject: [PATCH 12/13] chore: change comment message and file name --- .github/workflows/global-replicator.yml | 2 +- .github/workflows/{autoupdate-fork.yml => update-pr.yml} | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) rename .github/workflows/{autoupdate-fork.yml => update-pr.yml} (84%) diff --git a/.github/workflows/global-replicator.yml b/.github/workflows/global-replicator.yml index 53c6d373..66d6e449 100644 --- a/.github/workflows/global-replicator.yml +++ b/.github/workflows/global-replicator.yml @@ -138,7 +138,7 @@ jobs: uses: derberg/manage-files-in-multiple-repositories@beecbe897cf5ed7f3de5a791a3f2d70102fe7c25 with: github_token: ${{ secrets.GH_TOKEN }} - patterns_to_include: .github/workflows/scripts,.github/workflows/automerge-for-humans-add-ready-to-merge-or-do-not-merge-label.yml,.github/workflows/add-good-first-issue-labels.yml,.github/workflows/automerge-for-humans-merging.yml,.github/workflows/automerge-for-humans-remove-ready-to-merge-label-on-edit.yml,.github/workflows/automerge-orphans.yml,.github/workflows/automerge.yml,.github/workflows/autoupdate.yml,.github/workflows/help-command.yml,.github/workflows/issues-prs-notifications.yml,.github/workflows/lint-pr-title.yml,.github/workflows/notify-tsc-members-mention.yml,.github/workflows/stale-issues-prs.yml,.github/workflows/welcome-first-time-contrib.yml,.github/workflows/release-announcements.yml,.github/workflows/bounty-program-commands.yml,.github/workflows/please-take-a-look-command.yml,.github/workflows/autoupdate-fork.yml + patterns_to_include: .github/workflows/scripts,.github/workflows/automerge-for-humans-add-ready-to-merge-or-do-not-merge-label.yml,.github/workflows/add-good-first-issue-labels.yml,.github/workflows/automerge-for-humans-merging.yml,.github/workflows/automerge-for-humans-remove-ready-to-merge-label-on-edit.yml,.github/workflows/automerge-orphans.yml,.github/workflows/automerge.yml,.github/workflows/autoupdate.yml,.github/workflows/help-command.yml,.github/workflows/issues-prs-notifications.yml,.github/workflows/lint-pr-title.yml,.github/workflows/notify-tsc-members-mention.yml,.github/workflows/stale-issues-prs.yml,.github/workflows/welcome-first-time-contrib.yml,.github/workflows/release-announcements.yml,.github/workflows/bounty-program-commands.yml,.github/workflows/please-take-a-look-command.yml,.github/workflows/update-pr.yml committer_username: asyncapi-bot committer_email: info@asyncapi.io commit_message: "ci: update of files from global .github repo" diff --git a/.github/workflows/autoupdate-fork.yml b/.github/workflows/update-pr.yml similarity index 84% rename from .github/workflows/autoupdate-fork.yml rename to .github/workflows/update-pr.yml index 745eac26..c6f36561 100644 --- a/.github/workflows/autoupdate-fork.yml +++ b/.github/workflows/update-pr.yml @@ -7,14 +7,14 @@ # This workflow will be distributed to all repositories in the AsyncAPI organization -name: Autoupdate PR branches from fork +name: Update PR branches from fork on: issue_comment: types: [created] jobs: - autoupdate-pr: + update-pr: if: > startsWith(github.repository, 'asyncapi/') && github.event.issue.pull_request && @@ -83,8 +83,11 @@ jobs: ) ) { // Add comment to PR if the bot doesn't have permissions to update the PR + const comment = `@${context.actor} The updation of PR has failed. It can be due to one of the following reasons: + - I don't have permissions to update this PR. To update your fork with upstream using bot you need to to enable [Allow edits from maintainers](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork) option in the PR. + - The fork is located in an organization, not under your personal profile. + - There may be a conflict in the PR. Please resolve the conflict and try again.`; - const comment = `@${context.actor} I don't have permissions to update this PR. Please ask the PR author to check the "Allow edits from maintainers" checkbox in the PR settings. Another possible reason for failure can due to the fork being in an organisation and not under a user.`; await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, From 3bfdc64867ea8d2c9db6987864ef6410ac6dd717 Mon Sep 17 00:00:00 2001 From: Lukasz Gornicki Date: Thu, 18 Apr 2024 12:32:34 +0200 Subject: [PATCH 13/13] message updated --- .github/workflows/update-pr.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/update-pr.yml b/.github/workflows/update-pr.yml index c6f36561..2fa19b0a 100644 --- a/.github/workflows/update-pr.yml +++ b/.github/workflows/update-pr.yml @@ -83,9 +83,9 @@ jobs: ) ) { // Add comment to PR if the bot doesn't have permissions to update the PR - const comment = `@${context.actor} The updation of PR has failed. It can be due to one of the following reasons: - - I don't have permissions to update this PR. To update your fork with upstream using bot you need to to enable [Allow edits from maintainers](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork) option in the PR. - - The fork is located in an organization, not under your personal profile. + const comment = `Hi @${context.actor}. Update of PR has failed. It can be due to one of the following reasons: + - I don't have permissions to update this PR. To update your fork with upstream using bot you need to enable [Allow edits from maintainers](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork) option in the PR. + - The fork is located in an organization, not under your personal profile. No solution for that. You are on your own with manual update. - There may be a conflict in the PR. Please resolve the conflict and try again.`; await github.rest.issues.createComment({ @@ -99,4 +99,4 @@ jobs: } else { core.setFailed(GraphQLError.message); } - } \ No newline at end of file + }