Skip to content

Update to new nothunks #2481

Update to new nothunks

Update to new nothunks #2481

Workflow file for this run

name: Check Changelog
on:
pull_request:
types: [ opened, synchronize, labeled, unlabeled ]
jobs:
check-changelog:
runs-on: [ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Find Changed Files in changelog.d
id: changed-files
uses: tj-actions/changed-files@v40
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.");
}