Skip to content

Commit

Permalink
translate to pwsh
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmrdavid authored Apr 11, 2024
1 parent 53051e1 commit 36d459d
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions .github/workflows/guarantee-release-notes.yml
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
}

0 comments on commit 36d459d

Please sign in to comment.