Update nix documentation the README #155
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
name: Check Changelog | |
on: | |
pull_request: | |
types: [ opened, synchronize, labeled, unlabeled ] | |
jobs: | |
check-changelog: | |
runs-on: [ubuntu-latest] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3.3.0 | |
- name: Find Changed Files in changelog.d | |
id: changed-files | |
uses: tj-actions/changed-files@v35 | |
with: | |
files: '**/changelog.d/**' | |
- name: Enforce New File or 'No Changelog Required' Label | |
uses: actions/github-script@v6 | |
# don't require changelogs for draft PRs | |
if: github.event.pull_request.draft == false | |
with: | |
script: | | |
function shouldCheckChangelog() { | |
return !${{ contains(github.event.pull_request.labels.*.name, 'No Changelog Required') }}; | |
} | |
function getNewChangelogFiles() { | |
const newFiles = '${{ steps.changed-files.outputs.added_files }}'.trim().split(' '); | |
// We check that added_files is the singleton array containing the empty string. | |
// This is probably a bug in tj-actions/changed-files | |
if (newFiles.length === 1 && newFiles[0] === "") { | |
return []; | |
} else { | |
return newFiles; | |
} | |
} | |
function checkChangelog() { | |
const newFiles = getNewChangelogFiles(); | |
if (newFiles.length == 0) { | |
core.info("No files were added by this PR in any of the **/changelog.d directories."); | |
core.info("Either commit a new file, or add the label 'No Changelog Required' to your PR."); | |
core.setFailed("Changelog check failed."); | |
} else { | |
core.info(`The following changelog files were added by this PR:\n${newFiles}`); | |
} | |
} | |
if (shouldCheckChangelog()) { | |
checkChangelog(); | |
} else { | |
core.info("PR contains the label 'No Changelog Required', skipping changelog check."); | |
} |