Skip to content

chore: update @asyncapi/generator to 1.10.14 version #372

chore: update @asyncapi/generator to 1.10.14 version

chore: update @asyncapi/generator to 1.10.14 version #372

# 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 the following labels:
# `ready-to-merge` and `do-not-merge` labels to get stuff merged or blocked from merging
# `autoupdate` to keep a branch up-to-date with the target branch
name: Label PRs # if proper comment added
on:
issue_comment:
types:
- created
jobs:
add-ready-to-merge-label:
if: >
github.event.issue.pull_request &&
github.event.issue.state != 'closed' &&
github.actor != 'asyncapi-bot' &&
(
contains(github.event.comment.body, '/ready-to-merge') ||
contains(github.event.comment.body, '/rtm' )
)
runs-on: ubuntu-latest
steps:
- name: Add ready-to-merge label
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GH_TOKEN }}
script: |
const prDetailsUrl = context.payload.issue.pull_request.url;
const { data: pull } = await github.request(prDetailsUrl);
const { draft: isDraft} = pull;
if(!isDraft) {
console.log('adding ready-to-merge label...');
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['ready-to-merge']
})
}
const { data: comparison } =
await github.rest.repos.compareCommitsWithBasehead({
owner: pull.head.repo.owner.login,
repo: pull.head.repo.name,
basehead: `${pull.base.label}...${pull.head.label}`,
});
if (comparison.behind_by !== 0 && pull.mergeable_state === 'behind') {
console.log(`This branch is behind the target by ${comparison.behind_by} commits`)
console.log('adding out-of-date comment...');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
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.
Thanks 😄`
})
}
add-do-not-merge-label:
if: >
github.event.issue.pull_request &&
github.event.issue.state != 'closed' &&
github.actor != 'asyncapi-bot' &&
(
contains(github.event.comment.body, '/do-not-merge') ||
contains(github.event.comment.body, '/dnm' )
)
runs-on: ubuntu-latest
steps:
- name: Add do-not-merge label
uses: actions/github-script@v6
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']
})
add-autoupdate-label:
if: >
github.event.issue.pull_request &&
github.event.issue.state != 'closed' &&
github.actor != 'asyncapi-bot' &&
(
contains(github.event.comment.body, '/autoupdate') ||
contains(github.event.comment.body, '/au' )
)
runs-on: ubuntu-latest
steps:
- name: Add autoupdate label
uses: actions/github-script@v6
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: ['autoupdate']
})