feat(changelog): WPB-16103 add changelog directory structure and scripts #9
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 verification | |
on: | |
pull_request: | |
branches: [master] | |
push: | |
branches: [master] | |
permissions: | |
contents: read | |
jobs: | |
commitlint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Setup node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: lts/* | |
- name: Install commitlint | |
run: npm install -D @commitlint/cli @commitlint/config-conventional | |
- name: Print versions | |
run: | | |
git --version | |
node --version | |
npm --version | |
npx commitlint --version | |
- name: Validate current commit (last commit) with commitlint | |
run: | | |
echo "export default { extends: ['@commitlint/config-conventional'] };" > commitlint.config.js | |
npx commitlint -g commitlint.config.js --last --verbose 2>/dev/null | |
- name: Check changelog.d changes in PR | |
run: | | |
BASE_SHA=${{ github.event.pull_request.base.sha }} | |
HEAD_SHA=${{ github.event.pull_request.head.sha }} | |
CHANGED_FILES=$(git diff --name-only $BASE_SHA $HEAD_SHA -- changelog.d/ | grep -vE "^$") | |
if [ -z "$CHANGED_FILES" ]; then | |
echo "No files changed in changelog.d/" | |
exit 1 | |
fi | |
LINE_COUNT=$(git diff --unified=0 $BASE_SHA $HEAD_SHA -- changelog.d/ 2>/dev/null | grep -E "^\+|^\-" | grep -vE "^(\+\+\+|\-\-\-)" | wc -l) | |
if [ "$LINE_COUNT" -le 1 ]; then | |
echo "Changelog.d has one or zero lines changed: $LINE_COUNT lines" | |
exit 1 | |
fi | |
done |