Skip to content

[PLT-6847] Payouts new API integration #29

[PLT-6847] Payouts new API integration

[PLT-6847] Payouts new API integration #29

name: Check changelog
on:
pull_request:
types:
- opened
- synchronize
- labeled
- unlabeled
jobs:
check-changelog:
runs-on: ubuntu-latest
steps:
- name: 📥 Checkout repository
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
return newFiles.length === 1 && newFiles[0] === "" ? [] : 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.")