diff --git a/.github/workflows/automerge-for-humans-merging.yml b/.github/workflows/automerge-for-humans-merging.yml index 9ba0be90..8f193aab 100644 --- a/.github/workflows/automerge-for-humans-merging.yml +++ b/.github/workflows/automerge-for-humans-merging.yml @@ -18,30 +18,69 @@ on: jobs: automerge-for-humans: - 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 + # it runs only if PR actor is not a bot, at least not a bot that we know + 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]') runs-on: ubuntu-latest steps: - - name: Get list of authors - uses: sergeysova/jq-action@v2 + - name: Get PR authors id: authors + uses: actions/github-script@v7 with: - # This cmd does following (line by line): - # 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. - # 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. - # 3. Grabs the data we need for adding the `Co-authored-by: ...` lines later and puts it into objects to be used later on. - # 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. - # 5. Removes repeated authors (authors can have more than one commit in the PR). - # 6. Builds the `Co-authored-by: ...` lines with actual info. - # 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). - cmd: | - curl -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ secrets.GH_TOKEN }}" "${{github.event.pull_request._links.commits.href}}?per_page=100" | - jq -r '[.[] - | {name: .commit.author.name, email: .commit.author.email, login: .author.login}] - | map(select(.login != "${{github.event.pull_request.user.login}}")) - | unique - | map("Co-authored-by: " + .name + " <" + .email + ">") - | join("\n")' - multiline: true + script: | + // Get paginated list of all commits in the PR + try { + const commitOpts = github.rest.pulls.listCommits.endpoint.merge({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.issue.number + }); + + const commits = await github.paginate(commitOpts); + return commits; + } catch (error) { + core.setFailed(error.message); + return []; + } + + - name: Create commit message + id: create-commit-message + uses: actions/github-script@v7 + with: + script: | + const commits = ${{ steps.authors.outputs.result }}; + + if (commits.length === 0) { + core.setFailed('No commits found in the PR'); + return ''; + } + + // Get unique authors from the commits list + const authors = commits.reduce((acc, commit) => { + const username = commit.author?.login || commit.commit.author?.name; + if (username && !acc[username]) { + acc[username] = { + name: commit.commit.author?.name, + email: commit.commit.author?.email, + } + } + + return acc; + }, {}); + + // Create a string of the form "Co-authored-by: Name " + // ref: https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/creating-a-commit-with-multiple-authors + const coAuthors = Object.values(authors).map(author => { + return `Co-authored-by: ${author.name} <${author.email}>`; + }).join('\n'); + + core.debug(coAuthors);; + + return coAuthors; + - name: Automerge PR uses: pascalgn/automerge-action@22948e0bc22f0aa673800da838595a3e7347e584 #v0.15.6 https://github.com/pascalgn/automerge-action/releases/tag/v0.15.6 env: @@ -50,6 +89,6 @@ jobs: MERGE_METHOD: "squash" # Using the output of the previous step (`Co-authored-by: ...` lines) as commit description. # 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 - MERGE_COMMIT_MESSAGE: "{pullRequest.title} (#{pullRequest.number})\n\n\n${{ steps.authors.outputs.value }}" + MERGE_COMMIT_MESSAGE: "{pullRequest.title} (#{pullRequest.number})\n\n\n${{ fromJSON(steps.create-commit-message.outputs.result) }}" MERGE_RETRIES: "20" MERGE_RETRY_SLEEP: "30000" diff --git a/.github/workflows/help-command.yml b/.github/workflows/help-command.yml index 3f4dcbc4..12f5a94c 100644 --- a/.github/workflows/help-command.yml +++ b/.github/workflows/help-command.yml @@ -58,5 +58,6 @@ jobs: At the moment the following comments are supported in issues: - \`/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\`. - example: \`/gfi js\` or \`/good-first-issue ci-cd\`` + example: \`/gfi js\` or \`/good-first-issue ci-cd\` + - \`/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\`.` }) \ No newline at end of file diff --git a/.github/workflows/if-nodejs-pr-testing.yml b/.github/workflows/if-nodejs-pr-testing.yml index 66ea6552..462e6131 100644 --- a/.github/workflows/if-nodejs-pr-testing.yml +++ b/.github/workflows/if-nodejs-pr-testing.yml @@ -14,7 +14,9 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-latest, windows-latest] + # Using macos-13 instead of latest (macos-14) due to an issue with Puppeteer and such runner. + # See: https://github.com/puppeteer/puppeteer/issues/12327 and https://github.com/asyncapi/parser-js/issues/1001 + os: [ubuntu-latest, macos-13, windows-latest] steps: - if: > !github.event.pull_request.draft && !( diff --git a/.github/workflows/issues-prs-notifications.yml b/.github/workflows/issues-prs-notifications.yml index 78ebe960..b8b20c6b 100644 --- a/.github/workflows/issues-prs-notifications.yml +++ b/.github/workflows/issues-prs-notifications.yml @@ -20,8 +20,6 @@ jobs: name: Notify slack on every new issue runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v3 - name: Convert markdown to slack markdown for issue uses: asyncapi/.github/.github/actions/slackify-markdown@master id: issuemarkdown @@ -40,8 +38,6 @@ jobs: name: Notify slack on every new pull request runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v3 - name: Convert markdown to slack markdown for pull request uses: asyncapi/.github/.github/actions/slackify-markdown@master id: prmarkdown @@ -60,8 +56,6 @@ jobs: name: Notify slack on every new pull request runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v3 - name: Convert markdown to slack markdown for pull request uses: asyncapi/.github/.github/actions/slackify-markdown@master id: discussionmarkdown diff --git a/.github/workflows/transfer-issue.yml b/.github/workflows/transfer-issue.yml new file mode 100644 index 00000000..06cb1ed9 --- /dev/null +++ b/.github/workflows/transfer-issue.yml @@ -0,0 +1,57 @@ +# This action 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: Transfer Issues between repositories + +on: + issue_comment: + types: + - created + +jobs: + transfer: + 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'))}} + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + - name: Extract Input + id: extract_step + run: | + COMMENT="${{github.event.comment.body}}" + REPO=$(echo $COMMENT | awk '{print $2}') + echo repo=$REPO >> $GITHUB_OUTPUT + - name: Check Repo + uses: actions/github-script@v7 + with: + github-token: ${{secrets.GH_TOKEN}} + script: | + const r = "${{github.repository}}" + const [owner, repo] = r.split('/') + const repoToMove = process.env.REPO_TO_MOVE + const issue_number = context.issue.number + try { + const {data} = await github.rest.repos.get({ + owner, + repo: repoToMove + }) + }catch (e) { + const body = `${repoToMove} is not a repo under ${owner}. You can only transfer issue to repos that belong to the same organization.` + await github.rest.issues.createComment({ + owner, + repo, + issue_number, + body + }) + process.exit(1) + } + env: + REPO_TO_MOVE: ${{steps.extract_step.outputs.repo}} + - name: Transfer Issue + id: transferIssue + working-directory: ./ + run: | + gh issue transfer ${{github.event.issue.number}} asyncapi/${{steps.extract_step.outputs.repo}} + env: + GH_TOKEN: ${{ secrets.GH_TOKEN }} + diff --git a/.github/workflows/update-maintainers-trigger.yaml b/.github/workflows/update-maintainers-trigger.yaml new file mode 100644 index 00000000..12fc4abe --- /dev/null +++ b/.github/workflows/update-maintainers-trigger.yaml @@ -0,0 +1,28 @@ +# This action 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: Trigger MAINTAINERS.yaml file update + +on: + push: + branches: [ master ] + paths: + # Check all valid CODEOWNERS locations: + # https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners#codeowners-file-location + - 'CODEOWNERS' + - '.github/CODEOWNERS' + - '.docs/CODEOWNERS' + +jobs: + trigger-maintainers-update: + name: Trigger updating MAINTAINERS.yaml because of CODEOWNERS change + runs-on: ubuntu-latest + + steps: + - name: Repository Dispatch + uses: peter-evans/repository-dispatch@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # https://github.com/peter-evans/repository-dispatch/releases/tag/v3.0.0 + with: + # The PAT with the 'public_repo' scope is required + token: ${{ secrets.GH_TOKEN }} + repository: ${{ github.repository_owner }}/community + event-type: trigger-maintainers-update