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 new file mode 100644 index 0000000..68f3960 --- /dev/null +++ b/.github/workflows/automerge-for-humans-add-ready-to-merge-or-do-not-merge-label.yml @@ -0,0 +1,54 @@ +#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 + +#Purpose of this workflow is to enable anyone to label PR with `ready-to-merge` and `do-not-merge` labels to get stuff merged or blocked from merging +name: Add ready-to-merge or do-not-merge label # if proper comment added + +on: + issue_comment: + types: + - created + +jobs: + parse-comment-and-add-ready: # for handling cases when you want to mark as ready to merge + if: github.event.issue.pull_request && github.event.issue.state != 'closed' && github.actor != 'asyncapi-bot' + runs-on: ubuntu-latest + steps: + - name: Check if PR is draft # such info is not available in the context of issue_comment event + uses: actions/github-script@v5 + id: checkDraft + with: + result-encoding: string + script: | + const prDetailsUrl = context.payload.issue.pull_request.url; + const response = await github.request(prDetailsUrl); + return response.data.draft; + - name: Add label + if: steps.checkDraft.outputs.result == 'false' && (contains(github.event.comment.body, '/ready-to-merge') || contains(github.event.comment.body, '/rtm' )) + uses: actions/github-script@v5 + with: + github-token: ${{ secrets.GH_TOKEN }} + script: | + github.rest.issues.addLabels({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: ['ready-to-merge'] + }) + + parse-comment-and-add-block: # for handling cases when you want to mark as do-not-merge + if: github.event.issue.pull_request && github.event.issue.state != 'closed' && github.actor != 'asyncapi-bot' + runs-on: ubuntu-latest + steps: + - name: Add label + if: contains(github.event.comment.body, '/do-not-merge') || contains(github.event.comment.body, '/dnm' ) + uses: actions/github-script@v5 + with: + github-token: ${{ secrets.GH_TOKEN }} + script: | + github.rest.issues.addLabels({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: ['do-not-merge'] + }) \ No newline at end of file diff --git a/.github/workflows/help-command.yml b/.github/workflows/help-command.yml new file mode 100644 index 0000000..0fac866 --- /dev/null +++ b/.github/workflows/help-command.yml @@ -0,0 +1,28 @@ +#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 + +name: Create help comment + +on: + issue_comment: + types: + - created + +jobs: + create_help_comment: + if: github.event.issue.pull_request + runs-on: ubuntu-latest + steps: + - uses: actions-ecosystem/action-create-comment@v1 + if: contains(github.event.comment.body, '/help') + with: + github_token: ${{ secrets.GH_TOKEN }} + body: | + Hello, @${{ github.actor }}! 👋🏼 + + I'm Genie from the magic lamp. Looks like somebody needs a hand! 🆘 + + At the moment the following comments are supported in pull requests: + + - `/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 \ No newline at end of file