-
Notifications
You must be signed in to change notification settings - Fork 272
46 lines (39 loc) · 1.79 KB
/
guarantee-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
name: Check release_notes.md is updated
on:
workflow_dispatch:
push:
branches: [ main, dev, dajusto/validate-release-notes-are-provided ]
paths:
- '*'
pull_request:
branches: [ main, dev, dajusto/validate-release-notes-are-provided ]
types: [labeled, unlabeled, synchronize] # Trigger on PR labeling events, or a PR push (synchronize)
paths:
- '.github/workflows/guarantee-release-notes.yml'
jobs:
build:
runs-on: ubuntu-latest
# Skip all validation if label 'no-release-notes' is applied to the PR
if: ${{ !contains(github.event.pull_request.labels.*.name, 'no-release-notes') }}
steps:
- uses: actions/checkout@v2
- name: Check `release_notes.md`
id: check_changes
shell: pwsh
run: |
Write-Host "Checking for changes in release_notes.md..."
$latestCommitInPR = ${{ github.sha }}
$latestCommitInTargetBranch = ${{ github.event.before }}
# Get list of files changed in this PR
$changedFiles = git diff --name-only latestCommitInTargetBranch $latestCommitInPR
# If `release_notes.md` was modified, the PR passes the validation.
# If it's not modified, fail and instruct author on what to do (either modify it or add 'no-release-notes' label)
if ($changedFiles -match "release_notes.md") {
Write-Host "release_notes.md was modified. Pass!"
} else {
$errorMessage = "This PR does not update `release_notes.md`. If the PR should be included " +
"in the next release's release notes, please update this file. If the PR should not be included, " +
"then please add the label `no-release-notes` to the PR."
Write-Error $errorMessage
exit 1 # Fail the GH action
}