Skip to content

Commit

Permalink
chore: in release-please PRs, at-mention participating authors (#340)
Browse files Browse the repository at this point in the history
* chore: add action to mention contributors in release

* checkout everything so comparison works

* use origin/

* returns .stdout

* don't match first parens

* format nicely

* format

* update text

* is fetch-depth 0 needed?

* yes it is

* chore: parallelise calls

* look at .login
  • Loading branch information
Skn0tt authored Jul 5, 2022
1 parent 7b741b4 commit 6a79236
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/release-please-mention-contributors.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
on:
pull_request:
paths:
- CHANGELOG.md

name: "release-please: mention contributors"
jobs:
mention-contributors:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/github-script@v6
id: find-authors
with:
script: |
const { stdout: diff } = await exec.getExecOutput("git diff origin/${{ github.base_ref }} -U0 CHANGELOG.md")
console.log({ diff })
const COMMIT_URL_REGEX = /\/commit\/(\w+)\)/g
const matches = [...diff.matchAll(COMMIT_URL_REGEX)]
const authors = (await Promise.all(matches.map(async match => {
const ref = match[1]
const [owner, repo] = "${{ github.repository }}".split("/")
const commit = await github.rest.repos.getCommit({ owner, repo, ref })
return commit.data.author?.login
}))).filter(Boolean)
console.log({ authors })
core.setOutput('authors', authors.map(login => "@" + login).join(", "))
- name: Find existing comment
uses: peter-evans/find-comment@v2
id: existing-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: "This contains contributions by "

- name: Create or update comment
uses: peter-evans/create-or-update-comment@v2
with:
comment-id: ${{ steps.existing-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
This contains contributions by ${{ steps.find-authors.outputs.authors }}.
Release by merging this PR.
edit-mode: replace
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

* **deps:** update module go.mongodb.org/mongo-driver to v1.9.0 ([#324](https://github.com/netlify/netlify-commons/issues/324)) ([42cde20](https://github.com/netlify/netlify-commons/commit/42cde20b8049a705ffb503bd1098e94e1977c6ae))

* **feat:** this is a test entry ([bf982f57](https://github.com/netlify/netlify-commons/commit/bf982f574dcf33b4227adfd985037ef551ffdc17))

## [0.61.0](https://github.com/netlify/netlify-commons/compare/v0.60.1...v0.61.0) (2022-03-03)


Expand Down

0 comments on commit 6a79236

Please sign in to comment.