Skip to content

Commit 751dc3d

Browse files
authored
Merge branch 'master' into issue-1075-title-function-missing
2 parents 92c1b72 + 791cfff commit 751dc3d

File tree

4 files changed

+128
-25
lines changed

4 files changed

+128
-25
lines changed

.github/workflows/automerge-for-humans-merging.yml

Lines changed: 66 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,75 @@ on:
1818

1919
jobs:
2020
automerge-for-humans:
21-
if: github.event.pull_request.draft == false && (github.event.pull_request.user.login != 'asyncapi-bot' || github.event.pull_request.user.login != 'dependabot[bot]' || github.event.pull_request.user.login != 'dependabot-preview[bot]') #it runs only if PR actor is not a bot, at least not a bot that we know
21+
# it runs only if PR actor is not a bot, at least not a bot that we know
22+
if: |
23+
github.event.pull_request.draft == false &&
24+
(github.event.pull_request.user.login != 'asyncapi-bot' ||
25+
github.event.pull_request.user.login != 'dependabot[bot]' ||
26+
github.event.pull_request.user.login != 'dependabot-preview[bot]')
2227
runs-on: ubuntu-latest
2328
steps:
24-
- name: Get list of authors
25-
uses: sergeysova/jq-action@v2
29+
- name: Get PR authors
2630
id: authors
31+
uses: actions/github-script@v7
2732
with:
28-
# This cmd does following (line by line):
29-
# 1. CURL querying the list of commits of the current PR via GH API. Why? Because the current event payload does not carry info about the commits.
30-
# 2. Iterates over the previous returned payload, and creates an array with the filtered results (see below) so we can work wit it later. An example of payload can be found in https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#webhook-payload-example-34.
31-
# 3. Grabs the data we need for adding the `Co-authored-by: ...` lines later and puts it into objects to be used later on.
32-
# 4. Filters the results by excluding the current PR sender. We don't need to add it as co-author since is the PR creator and it will become by default the main author.
33-
# 5. Removes repeated authors (authors can have more than one commit in the PR).
34-
# 6. Builds the `Co-authored-by: ...` lines with actual info.
35-
# 7. Transforms the array into plain text. Thanks to this, the actual stdout of this step can be used by the next Workflow step (wich is basically the automerge).
36-
cmd: |
37-
curl -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.GH_TOKEN }}" "${{github.event.pull_request._links.commits.href}}?per_page=100" |
38-
jq -r '[.[]
39-
| {name: .commit.author.name, email: .commit.author.email, login: .author.login}]
40-
| map(select(.login != "${{github.event.pull_request.user.login}}"))
41-
| unique
42-
| map("Co-authored-by: " + .name + " <" + .email + ">")
43-
| join("\n")'
44-
multiline: true
33+
script: |
34+
// Get paginated list of all commits in the PR
35+
try {
36+
const commitOpts = github.rest.pulls.listCommits.endpoint.merge({
37+
owner: context.repo.owner,
38+
repo: context.repo.repo,
39+
pull_number: context.issue.number
40+
});
41+
42+
const commits = await github.paginate(commitOpts);
43+
44+
if (commits.length === 0) {
45+
core.setFailed('No commits found in the PR');
46+
return '';
47+
}
48+
49+
// Get unique authors from the commits list
50+
const authors = commits.reduce((acc, commit) => {
51+
const username = commit.author?.login || commit.commit.author?.name;
52+
if (username && !acc[username]) {
53+
acc[username] = {
54+
name: commit.commit.author?.name,
55+
email: commit.commit.author?.email,
56+
}
57+
}
58+
59+
return acc;
60+
}, {});
61+
62+
return authors;
63+
} catch (error) {
64+
core.setFailed(error.message);
65+
return [];
66+
}
67+
68+
- name: Create commit message
69+
id: create-commit-message
70+
uses: actions/github-script@v7
71+
with:
72+
script: |
73+
const authors = ${{ steps.authors.outputs.result }};
74+
75+
if (Object.keys(authors).length === 0) {
76+
core.setFailed('No authors found in the PR');
77+
return '';
78+
}
79+
80+
// Create a string of the form "Co-authored-by: Name <email>"
81+
// ref: https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/creating-a-commit-with-multiple-authors
82+
const coAuthors = Object.values(authors).map(author => {
83+
return `Co-authored-by: ${author.name} <${author.email}>`;
84+
}).join('\n');
85+
86+
core.debug(coAuthors);;
87+
88+
return coAuthors;
89+
4590
- name: Automerge PR
4691
uses: pascalgn/automerge-action@22948e0bc22f0aa673800da838595a3e7347e584 #v0.15.6 https://github.com/pascalgn/automerge-action/releases/tag/v0.15.6
4792
env:
@@ -50,6 +95,6 @@ jobs:
5095
MERGE_METHOD: "squash"
5196
# Using the output of the previous step (`Co-authored-by: ...` lines) as commit description.
5297
# Important to keep 2 empty lines as https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/creating-a-commit-with-multiple-authors#creating-co-authored-commits-on-the-command-line mentions
53-
MERGE_COMMIT_MESSAGE: "{pullRequest.title} (#{pullRequest.number})\n\n\n${{ steps.authors.outputs.value }}"
98+
MERGE_COMMIT_MESSAGE: "{pullRequest.title} (#{pullRequest.number})\n\n\n${{ fromJSON(steps.create-commit-message.outputs.result) }}"
5499
MERGE_RETRIES: "20"
55100
MERGE_RETRY_SLEEP: "30000"

.github/workflows/help-command.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,6 @@ jobs:
5858
At the moment the following comments are supported in issues:
5959

6060
- \`/good-first-issue {js | ts | java | go | docs | design | ci-cd}\` or \`/gfi {js | ts | java | go | docs | design | ci-cd}\` - label an issue as a \`good first issue\`.
61-
example: \`/gfi js\` or \`/good-first-issue ci-cd\``
61+
example: \`/gfi js\` or \`/good-first-issue ci-cd\`
62+
- \`/transfer-issue {repo-name}\` or \`/ti {repo-name}\` - transfer issue from the source repository to the other repository passed by the user. example: \`/ti cli\` or \`/transfer-issue cli\`.`
6263
})

.github/workflows/transfer-issue.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
name: Transfer Issues between repositories
5+
6+
on:
7+
issue_comment:
8+
types:
9+
- created
10+
11+
jobs:
12+
transfer:
13+
if: ${{(!github.event.issue.pull_request && github.event.issue.state != 'closed' && github.actor != 'asyncapi-bot') && (startsWith(github.event.comment.body, '/transfer-issue') || startsWith(github.event.comment.body, '/ti'))}}
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout Repository
17+
uses: actions/checkout@v4
18+
- name: Extract Input
19+
id: extract_step
20+
run: |
21+
COMMENT="${{github.event.comment.body}}"
22+
REPO=$(echo $COMMENT | awk '{print $2}')
23+
echo repo=$REPO >> $GITHUB_OUTPUT
24+
- name: Check Repo
25+
uses: actions/github-script@v7
26+
with:
27+
github-token: ${{secrets.GH_TOKEN}}
28+
script: |
29+
const r = "${{github.repository}}"
30+
const [owner, repo] = r.split('/')
31+
const repoToMove = process.env.REPO_TO_MOVE
32+
const issue_number = context.issue.number
33+
try {
34+
const {data} = await github.rest.repos.get({
35+
owner,
36+
repo: repoToMove
37+
})
38+
}catch (e) {
39+
const body = `${repoToMove} is not a repo under ${owner}. You can only transfer issue to repos that belong to the same organization.`
40+
await github.rest.issues.createComment({
41+
owner,
42+
repo,
43+
issue_number,
44+
body
45+
})
46+
process.exit(1)
47+
}
48+
env:
49+
REPO_TO_MOVE: ${{steps.extract_step.outputs.repo}}
50+
- name: Transfer Issue
51+
id: transferIssue
52+
working-directory: ./
53+
run: |
54+
gh issue transfer ${{github.event.issue.number}} asyncapi/${{steps.extract_step.outputs.repo}}
55+
env:
56+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
57+

.github/workflows/update-docs-on-docs-commits.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
uses: asyncapi/.github/.github/actions/get-node-version-from-package-lock@master
2727
id: lockversion
2828
- name: Use Node.js
29-
uses: actions/setup-node@v3
29+
uses: actions/setup-node@v4
3030
with:
3131
node-version: "${{ steps.lockversion.outputs.version }}"
3232
cache: 'npm'
@@ -36,7 +36,7 @@ jobs:
3636
- name: Regenerate docs
3737
run: npm run generate:assets --if-present
3838
- name: Create Pull Request with updated docs
39-
uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 # uses 5.0.2 https://github.com/peter-evans/create-pull-request/releases/tag/v5.0.2
39+
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # uses 7.0.8 https://github.com/peter-evans/create-pull-request/releases/tag/v7.0.8
4040
with:
4141
token: ${{ secrets.GH_TOKEN }}
4242
commit-message: 'chore: update generated docs'
@@ -47,7 +47,7 @@ jobs:
4747
branch: gen-docs-update/${{ github.job }}
4848
- name: Report workflow status to Slack
4949
if: failure() # Only, on failure, send a message on the 94_bot-failing-ci slack channel
50-
uses: 8398a7/action-slack@fbd6aa58ba854a740e11a35d0df80cb5d12101d8 #using https://github.com/8398a7/action-slack/releases/tag/v3.15.1
50+
uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 #using https://github.com/8398a7/action-slack/releases/tag/v3.16.2
5151
with:
5252
status: ${{ job.status }}
5353
fields: repo,action,workflow

0 commit comments

Comments
 (0)