|
15 | 15 |
|
16 | 16 | jobs:
|
17 | 17 | check-change-note:
|
| 18 | + env: |
| 19 | + REPO: ${{ github.repository }} |
| 20 | + PULL_REQUEST_NUMBER: ${{ github.event.number }} |
| 21 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
18 | 22 | runs-on: ubuntu-latest
|
19 | 23 | steps:
|
| 24 | + |
20 | 25 | - name: Fail if no change note found. To fix, either add one, or add the `no-change-note-required` label.
|
21 | 26 | if: |
|
22 | 27 | github.event.pull_request.draft == false &&
|
23 | 28 | !contains(github.event.pull_request.labels.*.name, 'no-change-note-required')
|
24 |
| - env: |
25 |
| - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
26 | 29 | run: |
|
27 |
| - gh api 'repos/${{github.repository}}/pulls/${{github.event.number}}/files' --paginate --jq 'any(.[].filename ; test("/change-notes/.*[.]md$"))' | |
28 |
| - grep true -c |
| 30 | + change_note_files=$(gh api "repos/$REPO/pulls/$PULL_REQUEST_NUMBER/files" --paginate --jq '.[].filename | select(test("/change-notes/.*[.]md$"))') |
| 31 | + |
| 32 | + if [ -z "$change_note_files" ]; then |
| 33 | + echo "No change note found. Either add one, or add the 'no-change-note-required' label." |
| 34 | + exit 1 |
| 35 | + fi |
| 36 | +
|
| 37 | + echo "Change notes found:" |
| 38 | + echo "$change_note_files" |
| 39 | +
|
29 | 40 | - name: Fail if the change note filename doesn't match the expected format. The file name must be of the form 'YYYY-MM-DD.md', 'YYYY-MM-DD-{title}.md', where '{title}' is arbitrary text, or released/x.y.z.md for released change-notes
|
30 |
| - env: |
31 |
| - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
32 | 41 | run: |
|
33 |
| - gh api 'repos/${{github.repository}}/pulls/${{github.event.number}}/files' --paginate --jq '[.[].filename | select(test("/change-notes/.*[.]md$"))] | all(test("/change-notes/[0-9]{4}-[0-9]{2}-[0-9]{2}.*[.]md$") or test("/change-notes/released/[0-9]*[.][0-9]*[.][0-9]*[.]md$"))' | |
34 |
| - grep true -c |
| 42 | + bad_change_note_file_names=$(gh api "repos/$REPO/pulls/$PULL_REQUEST_NUMBER/files" --paginate --jq '[.[].filename | select(test("/change-notes/.*[.]md$"))][] | select((test("/change-notes/[0-9]{4}-[0-9]{2}-[0-9]{2}.*[.]md$") or test("/change-notes/released/[0-9]*[.][0-9]*[.][0-9]*[.]md$")) | not)') |
| 43 | +
|
| 44 | + if [ -n "$bad_change_note_file_names" ]; then |
| 45 | + echo "The following change note file names are invalid:" |
| 46 | + echo "$bad_change_note_file_names" |
| 47 | + exit 1 |
| 48 | + fi |
0 commit comments