-
Notifications
You must be signed in to change notification settings - Fork 253
81 lines (69 loc) · 3.03 KB
/
release_notes.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: release_notes
on:
workflow_dispatch:
inputs:
releasePr:
description: 'Enter release PR number'
required: true
type: number
issue_comment:
types: [created]
permissions:
contents: write
pull-requests: write
jobs:
release_notes:
runs-on: ubuntu-latest
# Run only if dispatched or comment on a pull request
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'issue_comment' && github.event.issue.pull_request && github.event.comment.body == 'run release_notes') }}
steps:
# Determine if the triggering_actor is allowed to run this action
# We only permit maintainers
# Not only is 'triggering_actor' common between the trigger events it will also change if someone re-runs an old job
- name: check if triggering_actor is allowed to generate notes
env:
GITHUB_TOKEN: ${{ github.token }}
COMMENTER: ${{ github.triggering_actor && github.triggering_actor || 'empty_triggering_actor' }}
API_ENDPOINT: /repos/${{ github.repository }}/collaborators?permission=maintain
shell: bash
run: |
if [ $COMMENTER = "empty_triggering_actor" ]; then exit 1; fi
set -o pipefail
if gh api "$API_ENDPOINT" --paginate --jq ".[].login" | grep -q "^$COMMENTER\$"; then
echo "$COMMENTER permitted to trigger notes!" && exit 0
else
echo "$COMMENTER not permitted to trigger notes" && exit 1
fi
# checkout the HEAD ref from prNumber
- uses: actions/checkout@v4
with:
ref: refs/pull/${{ github.event_name == 'issue_comment' && github.event.issue.number || inputs.releasePr }}/head
# Setup Node.js and npm install
- name: Install Node and dependencies
uses: mongodb-labs/drivers-github-tools/node/setup@v2
# See: https://github.com/googleapis/release-please/issues/1274
# Get the PRs that are in this release
# Outputs a list of comma seperated PR numbers, parsed from HISTORY.md
- id: pr_list
run: node .github/scripts/pr_list.mjs
env:
GITHUB_TOKEN: ${{ github.token }}
# From the list of PRs, gather the highlight sections of the PR body
# output JSON with "highlights" key (to preserve newlines)
- id: highlights
run: node .github/scripts/highlights.mjs
env:
GITHUB_TOKEN: ${{ github.token }}
PR_LIST: ${{ steps.pr_list.outputs.pr_list }}
REPOSITORY: ${{ github.repository }}
# The combined output is available
- id: release_notes
run: node .github/scripts/release_notes.mjs
env:
GITHUB_TOKEN: ${{ github.token }}
HIGHLIGHTS: ${{ steps.highlights.outputs.highlights }}
# Update the release PR body
- run: gh pr edit ${{ github.event_name == 'issue_comment' && github.event.issue.number || inputs.releasePr }} --body-file ${{ steps.release_notes.outputs.release_notes_path }}
shell: bash
env:
GITHUB_TOKEN: ${{ github.token }}