Skip to content

Commit f01e6f3

Browse files
Merge branch 'master' into issue-414
2 parents a3118a0 + 5921f9d commit f01e6f3

File tree

3 files changed

+29
-38
lines changed

3 files changed

+29
-38
lines changed

.github/workflows/automerge-for-humans-add-ready-to-merge-or-do-not-merge-label.yml

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -26,50 +26,45 @@ jobs:
2626
runs-on: ubuntu-latest
2727
steps:
2828

29-
- name: Check if PR is draft or is up-to-date # such info is not available in the context of issue_comment event
29+
- name: Add ready-to-merge label
3030
uses: actions/github-script@v5
31-
id: checkPR
3231
with:
33-
result-encoding: string
32+
github-token: ${{ secrets.GH_TOKEN }}
3433
script: |
35-
let isDraft = false;
36-
let isUpToDate = true;
3734
const prDetailsUrl = context.payload.issue.pull_request.url;
3835
const { data: pull } = await github.request(prDetailsUrl);
39-
isDraft = pull.draft;
36+
const { draft: isDraft} = pull;
37+
if(!isDraft) {
38+
console.log('adding ready-to-merge label...');
39+
github.rest.issues.addLabels({
40+
issue_number: context.issue.number,
41+
owner: context.repo.owner,
42+
repo: context.repo.repo,
43+
labels: ['ready-to-merge']
44+
})
45+
}
4046
4147
const { data: comparison } =
4248
await github.rest.repos.compareCommitsWithBasehead({
4349
owner: pull.head.repo.owner.login,
4450
repo: pull.head.repo.name,
45-
basehead: `${pull.head.label}...${pull.base.label}`,
51+
basehead: `${pull.base.label}...${pull.head.label}`,
4652
});
47-
if (comparison.behind_by !== 0) isUpToDate = false;
48-
return { isDraft, isUpToDate };
49-
50-
- uses: actions-ecosystem/action-create-comment@v1
51-
if: ${{ !steps.checkPR.outputs.result.isUpToDate }}
52-
with:
53-
github_token: ${{ secrets.GH_TOKEN }}
54-
body: |
55-
Hello, @${{ github.actor }}! 👋🏼
56-
This PR is not up to date with the base branch and can't be merged.
57-
You can add comment to this PR with text: `/autoupdate` or `/au`. This way you ask our bot to perform regular updates for you. 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. Otherwise the only option that you have is to manually update your branch with latest version of the base branch.
58-
Thanks 😄
59-
60-
- name: Add ready-to-merge label
61-
if: ${{ !steps.checkPR.outputs.result.isDraft }}
62-
uses: actions/github-script@v5
63-
with:
64-
github-token: ${{ secrets.GH_TOKEN }}
65-
script: |
66-
github.rest.issues.addLabels({
67-
issue_number: context.issue.number,
68-
owner: context.repo.owner,
69-
repo: context.repo.repo,
70-
labels: ['ready-to-merge']
71-
})
72-
53+
if (comparison.behind_by !== 0) {
54+
console.log(`This branch is behind the target by ${comparison.behind_by} commits`)
55+
console.log('adding out-of-date comment...');
56+
github.rest.issues.createComment({
57+
issue_number: context.issue.number,
58+
owner: context.repo.owner,
59+
repo: context.repo.repo,
60+
body: `Hello, @${{ github.actor }}! 👋🏼
61+
This PR is not up to date with the base branch and can't be merged.
62+
Please update your branch manually with the latest version of the base branch.
63+
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.
64+
Thanks 😄`
65+
})
66+
}
67+
7368
add-do-not-merge-label:
7469
if: >
7570
github.event.issue.pull_request &&

.github/workflows/autoupdate.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,9 @@ on:
1717
- 'dependabot/**'
1818
- 'bot/**'
1919
- 'all-contributors/**'
20-
pull_request:
21-
types:
22-
- labeled
2320

2421
jobs:
2522
autoupdate-for-bot:
26-
if: ${{ !github.event.issue.pull_request || contains(github.event.pull_request.labels.*.name, 'autoupdate') }}
2723
name: Autoupdate autoapproved PR created in the upstream
2824
runs-on: ubuntu-latest
2925
steps:

.github/workflows/help-command.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
2626
- `/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
2727
- `/do-not-merge` or `/dnm` - This comment will block automerging even if all conditions are met and ready-to-merge label is added
28-
- `/autoupdate` or `/au` - This comment will add `autoupdate` label to the PR and keeps your PR up-to-date to the target branch. Unless there is a merge conflict.
28+
- `/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.
2929
create_help_comment_issue:
3030
if: ${{ !github.event.issue.pull_request && contains(github.event.comment.body, '/help') && github.actor != 'asyncapi-bot' }}
3131
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)