-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
53051e1
commit 36d459d
Showing
1 changed file
with
21 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,41 @@ | ||
name: Guarantee release notes are provided | ||
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] | ||
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 | ||
if: ${{ !contains(github.event.pull_request.labels.*.name, 'does-not-need-release-note') }} | ||
# 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 for release_notes.md changes | ||
- name: Check `release_notes.md` | ||
id: check_changes | ||
shell: pwsh | ||
run: | | ||
echo "Checking for changes in release_notes.md..." | ||
if git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -q 'release_notes.md'; then | ||
echo "release_notes.md was modified. " | ||
echo "MODIFIED=true" >> $GITHUB_ENV | ||
else | ||
echo "release_notes.md was NOT modified." | ||
echo "MODIFIED=false" >> $GITHUB_ENV | ||
fi | ||
- name: Fail if release_notes.md was not modified | ||
if: env.MODIFIED == 'false' | ||
run: | | ||
echo {{github.event.pull_request.labels.*.name.*.name}} | ||
echo "Error: release_notes.md must be updated in this PR." | ||
exit 1 | ||
Write-Host "Checking for changes in release_notes.md..." | ||
$changedFiles = git diff --name-only ${{ github.event.before }} ${{ github.sha }} | ||
# 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 | ||
} |