Upgrade checkout action; shell out less in validate-changelog #6
Workflow file for this run
This file contains hidden or 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
| name: Changelog | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened, labeled, unlabeled] | |
| jobs: | |
| validate: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| # We want to check modified files from base_ref (merge target) to the current commit, | |
| # so we need the full history of the current branch. | |
| fetch-depth: 0 | |
| - name: Check for skip label | |
| id: check-skip | |
| run: | | |
| if [[ "${{ contains(github.event.pull_request.labels.*.name, 'skip-changelog') }}" == "true" ]]; then | |
| echo "skip=true" >> $GITHUB_OUTPUT | |
| echo "Skipping changelog validation due to skip-changelog label" | |
| else | |
| echo "skip=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Validate changelog entry | |
| if: steps.check-skip.outputs.skip == 'false' | |
| run: | | |
| # --quiet implies --exit-code (but doesn't produce output). | |
| # --exit-code exits 1 if there are differences, or 0 if there are no differences. | |
| # So: this command exits 1 if CHANGELOG.md was changed between the base and HEAD, | |
| # or 0 if there are no diffs. | |
| if git diff --quiet origin/"${{ github.base_ref }}"...HEAD -- CHANGELOG.md; then | |
| echo "::error::No changelog entry found. Please add an entry to CHANGELOG.md or add the 'skip-changelog' label if this change does not require a changelog entry." | |
| exit 1 | |
| else | |
| echo "Changelog has been updated" | |
| fi |