Skip to content

Commit 6a79236

Browse files
authored
chore: in release-please PRs, at-mention participating authors (#340)
* 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
1 parent 7b741b4 commit 6a79236

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
on:
2+
pull_request:
3+
paths:
4+
- CHANGELOG.md
5+
6+
name: "release-please: mention contributors"
7+
jobs:
8+
mention-contributors:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
with:
13+
fetch-depth: 0
14+
15+
- uses: actions/github-script@v6
16+
id: find-authors
17+
with:
18+
script: |
19+
const { stdout: diff } = await exec.getExecOutput("git diff origin/${{ github.base_ref }} -U0 CHANGELOG.md")
20+
console.log({ diff })
21+
22+
const COMMIT_URL_REGEX = /\/commit\/(\w+)\)/g
23+
24+
const matches = [...diff.matchAll(COMMIT_URL_REGEX)]
25+
const authors = (await Promise.all(matches.map(async match => {
26+
const ref = match[1]
27+
const [owner, repo] = "${{ github.repository }}".split("/")
28+
const commit = await github.rest.repos.getCommit({ owner, repo, ref })
29+
return commit.data.author?.login
30+
}))).filter(Boolean)
31+
32+
console.log({ authors })
33+
core.setOutput('authors', authors.map(login => "@" + login).join(", "))
34+
35+
- name: Find existing comment
36+
uses: peter-evans/find-comment@v2
37+
id: existing-comment
38+
with:
39+
issue-number: ${{ github.event.pull_request.number }}
40+
comment-author: "github-actions[bot]"
41+
body-includes: "This contains contributions by "
42+
43+
- name: Create or update comment
44+
uses: peter-evans/create-or-update-comment@v2
45+
with:
46+
comment-id: ${{ steps.existing-comment.outputs.comment-id }}
47+
issue-number: ${{ github.event.pull_request.number }}
48+
body: |
49+
This contains contributions by ${{ steps.find-authors.outputs.authors }}.
50+
Release by merging this PR.
51+
edit-mode: replace

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
* **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))
2323

24+
* **feat:** this is a test entry ([bf982f57](https://github.com/netlify/netlify-commons/commit/bf982f574dcf33b4227adfd985037ef551ffdc17))
25+
2426
## [0.61.0](https://github.com/netlify/netlify-commons/compare/v0.60.1...v0.61.0) (2022-03-03)
2527

2628

0 commit comments

Comments
 (0)