|
| 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 |
0 commit comments