Skip to content

Commit 4a707e7

Browse files
committed
Merge branch 'master' into add-allComponent-functions
2 parents 1ac0843 + 748306a commit 4a707e7

9 files changed

+200
-97
lines changed

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ jobs:
5959
body: `Hello, @${{ github.actor }}! 👋🏼
6060
This PR is not up to date with the base branch and can't be merged.
6161
Please update your branch manually with the latest version of the base branch.
62-
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.
62+
PRO-TIP: To request an update from the upstream branch, simply comment \`/u\` or \`/update\` and our bot will handle the update operation promptly.
63+
64+
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.
6365
Thanks 😄`
6466
})
6567
}

.github/workflows/autoupdate.yml

+34-34
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
1-
# This action is centrally managed in https://github.com/asyncapi/.github/
2-
# 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
3-
4-
# This workflow is designed to work with:
5-
# - autoapprove and automerge workflows for dependabot and asyncapibot.
6-
# - 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
7-
8-
# It uses GitHub Action that auto-updates pull requests branches, whenever changes are pushed to their destination branch.
9-
# Autoupdating to latest destination branch works only in the context of upstream repo and not forks
10-
11-
name: autoupdate
12-
13-
on:
14-
push:
15-
branches-ignore:
16-
- 'version-bump/**'
17-
- 'dependabot/**'
18-
- 'bot/**'
19-
- 'all-contributors/**'
20-
21-
jobs:
22-
autoupdate-for-bot:
23-
if: startsWith(github.repository, 'asyncapi/')
24-
name: Autoupdate autoapproved PR created in the upstream
25-
runs-on: ubuntu-latest
26-
steps:
27-
- name: Autoupdating
28-
uses: docker://chinthakagodawita/autoupdate-action:v1
29-
env:
30-
GITHUB_TOKEN: '${{ secrets.GH_TOKEN_BOT_EVE }}'
31-
PR_FILTER: "labelled"
32-
PR_LABELS: "autoupdate"
33-
PR_READY_STATE: "ready_for_review"
34-
MERGE_CONFLICT_ACTION: "ignore"
1+
# This action is centrally managed in https://github.com/asyncapi/.github/
2+
# 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
3+
4+
# This workflow is designed to work with:
5+
# - autoapprove and automerge workflows for dependabot and asyncapibot.
6+
# - 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
7+
8+
# It uses GitHub Action that auto-updates pull requests branches, whenever changes are pushed to their destination branch.
9+
# Autoupdating to latest destination branch works only in the context of upstream repo and not forks
10+
11+
name: autoupdate
12+
13+
on:
14+
push:
15+
branches-ignore:
16+
- 'version-bump/**'
17+
- 'dependabot/**'
18+
- 'bot/**'
19+
- 'all-contributors/**'
20+
21+
jobs:
22+
autoupdate-for-bot:
23+
if: startsWith(github.repository, 'asyncapi/')
24+
name: Autoupdate autoapproved PR created in the upstream
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Autoupdating
28+
uses: docker://chinthakagodawita/autoupdate-action:v1
29+
env:
30+
GITHUB_TOKEN: '${{ secrets.GH_TOKEN_BOT_EVE }}'
31+
PR_FILTER: "labelled"
32+
PR_LABELS: "autoupdate"
33+
PR_READY_STATE: "ready_for_review"
34+
MERGE_CONFLICT_ACTION: "ignore"

.github/workflows/bump.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ jobs:
2626
run: test -e ./package.json && echo "exists=true" >> $GITHUB_OUTPUT || echo "exists=false" >> $GITHUB_OUTPUT
2727
- if: steps.packagejson.outputs.exists == 'true'
2828
name: Bumping latest version of this package in other repositories
29-
uses: derberg/npm-dependency-manager-for-your-github-org@3df56be95bcaa5c76a9c9a4af863ab151545b649 # using v6.-.- https://github.com/derberg/npm-dependency-manager-for-your-github-org/releases/tag/v6
29+
uses: derberg/npm-dependency-manager-for-your-github-org@1eafd3bf3974f21d395c1abac855cb04b295d570 # using v6.-.- https://github.com/derberg/npm-dependency-manager-for-your-github-org/releases/tag/v6
3030
with:
3131
github_token: ${{ secrets.GH_TOKEN }}
3232
committer_username: asyncapi-bot
3333
committer_email: [email protected]
34-
repos_to_ignore: spec,bindings,saunter
34+
repos_to_ignore: spec,bindings,saunter,server-api
35+
custom_id: "dependency update from asyncapi bot"

.github/workflows/help-command.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ jobs:
3131
3232
At the moment the following comments are supported in pull requests:
3333

34-
- \`/please-take-a-look` or \`/ptal\` - This comment will add a comment to the PR asking for attention from the reviewrs who have not reviewed the PR yet.
34+
- \`/please-take-a-look\` or \`/ptal\` - This comment will add a comment to the PR asking for attention from the reviewrs who have not reviewed the PR yet.
3535
- \`/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
3636
- \`/do-not-merge\` or \`/dnm\` - This comment will block automerging even if all conditions are met and ready-to-merge label is added
37-
- \`/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.`
37+
- \`/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.)
38+
- \`/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.`
3839
})
3940

4041
create_help_comment_issue:

.github/workflows/if-nodejs-pr-testing.yml

+12-12
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ jobs:
3939
run: |
4040
git config --global core.autocrlf false
4141
git config --global core.eol lf
42+
shell: bash
4243
- if: steps.should_run.outputs.shouldrun == 'true'
4344
name: Checkout repository
44-
uses: actions/checkout@v3
45+
uses: actions/checkout@v4
4546
- if: steps.should_run.outputs.shouldrun == 'true'
4647
name: Check if Node.js project and has package.json
4748
id: packagejson
@@ -53,27 +54,26 @@ jobs:
5354
id: lockversion
5455
- if: steps.packagejson.outputs.exists == 'true'
5556
name: Setup Node.js
56-
uses: actions/setup-node@v3
57+
uses: actions/setup-node@v4
5758
with:
5859
node-version: "${{ steps.lockversion.outputs.version }}"
59-
cache: 'npm'
60-
cache-dependency-path: '**/package-lock.json'
60+
- if: steps.lockversion.outputs.version == '18' && matrix.os == 'windows-latest'
61+
#npm cli 10 is buggy because of some cache issue
62+
name: Install npm cli 8
63+
shell: bash
64+
run: npm install -g [email protected]
6165
- if: steps.packagejson.outputs.exists == 'true'
6266
name: Install dependencies
63-
id: first-installation
67+
shell: bash
6468
run: npm ci
65-
continue-on-error: true
66-
- if: steps.first-installation.outcome != 'success' && steps.packagejson.outputs.exists == 'true'
67-
name: Clear NPM cache and install deps again
68-
run: |
69-
npm cache clean --force
70-
npm ci
7169
- if: steps.packagejson.outputs.exists == 'true'
7270
name: Test
7371
run: npm test --if-present
74-
- if: steps.packagejson.outputs.exists == 'true'
72+
- if: steps.packagejson.outputs.exists == 'true' && matrix.os == 'ubuntu-latest'
73+
#linting should run just one and not on all possible operating systems
7574
name: Run linter
7675
run: npm run lint --if-present
7776
- if: steps.packagejson.outputs.exists == 'true'
7877
name: Run release assets generation to make sure PR does not break it
78+
shell: bash
7979
run: npm run generate:assets --if-present

.github/workflows/if-nodejs-release.yml

+14-17
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ jobs:
3838
run: |
3939
git config --global core.autocrlf false
4040
git config --global core.eol lf
41+
shell: bash
4142
- name: Checkout repository
42-
uses: actions/checkout@v3
43+
uses: actions/checkout@v4
4344
- name: Check if Node.js project and has package.json
4445
id: packagejson
4546
run: test -e ./package.json && echo "exists=true" >> $GITHUB_OUTPUT || echo "exists=false" >> $GITHUB_OUTPUT
@@ -50,14 +51,18 @@ jobs:
5051
id: lockversion
5152
- if: steps.packagejson.outputs.exists == 'true'
5253
name: Setup Node.js
53-
uses: actions/setup-node@v3
54+
uses: actions/setup-node@v4
5455
with:
5556
node-version: "${{ steps.lockversion.outputs.version }}"
56-
cache: 'npm'
57-
cache-dependency-path: '**/package-lock.json'
57+
- if: steps.lockversion.outputs.version == '18' && matrix.os == 'windows-latest'
58+
name: Install npm cli 8
59+
shell: bash
60+
#npm cli 10 is buggy because of some cache issues
61+
run: npm install -g [email protected]
5862
- if: steps.packagejson.outputs.exists == 'true'
5963
name: Install dependencies
60-
run: npm install
64+
shell: bash
65+
run: npm ci
6166
- if: steps.packagejson.outputs.exists == 'true'
6267
name: Run test
6368
run: npm test --if-present
@@ -81,7 +86,7 @@ jobs:
8186
git config --global core.autocrlf false
8287
git config --global core.eol lf
8388
- name: Checkout repository
84-
uses: actions/checkout@v3
89+
uses: actions/checkout@v4
8590
- name: Check if Node.js project and has package.json
8691
id: packagejson
8792
run: test -e ./package.json && echo "exists=true" >> $GITHUB_OUTPUT || echo "exists=false" >> $GITHUB_OUTPUT
@@ -92,21 +97,13 @@ jobs:
9297
id: lockversion
9398
- if: steps.packagejson.outputs.exists == 'true'
9499
name: Setup Node.js
95-
uses: actions/setup-node@v3
100+
uses: actions/setup-node@v4
96101
with:
97102
node-version: "${{ steps.lockversion.outputs.version }}"
98-
cache: 'npm'
99-
cache-dependency-path: '**/package-lock.json'
100103
- if: steps.packagejson.outputs.exists == 'true'
101104
name: Install dependencies
102-
id: first-installation
105+
shell: bash
103106
run: npm ci
104-
continue-on-error: true
105-
- if: steps.first-installation.outcome != 'success' && steps.packagejson.outputs.exists == 'true'
106-
name: Clear NPM cache and install deps again
107-
run: |
108-
npm cache clean --force
109-
npm ci
110107
- if: steps.packagejson.outputs.exists == 'true'
111108
name: Add plugin for conventional commits for semantic-release
112109
run: npm install --save-dev [email protected]
@@ -131,4 +128,4 @@ jobs:
131128
fields: repo,action,workflow
132129
text: 'Release workflow failed in release job'
133130
env:
134-
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CI_FAIL_NOTIFY }}
131+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CI_FAIL_NOTIFY }}

.github/workflows/update-pr.yml

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# This workflow is centrally managed in https://github.com/asyncapi/.github/
2+
# 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
3+
4+
# This workflow will run on every comment with /update or /u. And will create merge-commits for the PR.
5+
# This also works with forks, not only with branches in the same repository/organization.
6+
# Currently, does not work with forks in different organizations.
7+
8+
# This workflow will be distributed to all repositories in the AsyncAPI organization
9+
10+
name: Update PR branches from fork
11+
12+
on:
13+
issue_comment:
14+
types: [created]
15+
16+
jobs:
17+
update-pr:
18+
if: >
19+
startsWith(github.repository, 'asyncapi/') &&
20+
github.event.issue.pull_request &&
21+
github.event.issue.state != 'closed' && (
22+
contains(github.event.comment.body, '/update') ||
23+
contains(github.event.comment.body, '/u')
24+
)
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Get Pull Request Details
28+
id: pr
29+
uses: actions/github-script@v7
30+
with:
31+
github-token: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}
32+
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
33+
script: |
34+
const prNumber = context.payload.issue.number;
35+
core.debug(`PR Number: ${prNumber}`);
36+
const { data: pr } = await github.rest.pulls.get({
37+
owner: context.repo.owner,
38+
repo: context.repo.repo,
39+
pull_number: prNumber
40+
});
41+
42+
// If the PR has conflicts, we don't want to update it
43+
const updateable = ['behind', 'blocked', 'unknown', 'draft', 'clean'].includes(pr.mergeable_state);
44+
console.log(`PR #${prNumber} is ${pr.mergeable_state} and is ${updateable ? 'updateable' : 'not updateable'}`);
45+
core.setOutput('updateable', updateable);
46+
47+
core.debug(`Updating PR #${prNumber} with head ${pr.head.sha}`);
48+
49+
return {
50+
id: pr.node_id,
51+
number: prNumber,
52+
head: pr.head.sha,
53+
}
54+
- name: Update the Pull Request
55+
if: steps.pr.outputs.updateable == 'true'
56+
uses: actions/github-script@v7
57+
with:
58+
github-token: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}
59+
script: |
60+
const mutation = `mutation update($input: UpdatePullRequestBranchInput!) {
61+
updatePullRequestBranch(input: $input) {
62+
pullRequest {
63+
mergeable
64+
}
65+
}
66+
}`;
67+
68+
const pr_details = ${{ steps.pr.outputs.result }};
69+
70+
try {
71+
const { data } = await github.graphql(mutation, {
72+
input: {
73+
pullRequestId: pr_details.id,
74+
expectedHeadOid: pr_details.head,
75+
}
76+
});
77+
} catch (GraphQLError) {
78+
core.debug(GraphQLError);
79+
if (
80+
GraphQLError.name === 'GraphqlResponseError' &&
81+
GraphQLError.errors.some(
82+
error => error.type === 'FORBIDDEN' || error.type === 'UNAUTHORIZED'
83+
)
84+
) {
85+
// Add comment to PR if the bot doesn't have permissions to update the PR
86+
const comment = `Hi @${context.actor}. Update of PR has failed. It can be due to one of the following reasons:
87+
- 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.
88+
- The fork is located in an organization, not under your personal profile. No solution for that. You are on your own with manual update.
89+
- There may be a conflict in the PR. Please resolve the conflict and try again.`;
90+
91+
await github.rest.issues.createComment({
92+
owner: context.repo.owner,
93+
repo: context.repo.repo,
94+
issue_number: context.issue.number,
95+
body: comment
96+
});
97+
98+
core.setFailed('Bot does not have permissions to update the PR');
99+
} else {
100+
core.setFailed(GraphQLError.message);
101+
}
102+
}

0 commit comments

Comments
 (0)