Add workflow for linting CHANGELOG.md #11
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: lint-changelog | |
on: | |
pull_request: | |
paths: | |
- CHANGELOG.md | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: '0' | |
- name: Install dependencies | |
run: | | |
pip install parse-changelog | |
- name: Parse changelog to JSON | |
run: | | |
parse-changelog --changelog ./CHANGELOG.md > _changelog.json | |
- name: Print parsed changelog | |
run: | | |
jq . _changelog.json | |
- name: Check if introduction is present | |
run: | | |
jq -e 'has("introduction")' _changelog.json || (echo "::error file=CHANGELOG.md,line=1,col=1,endColumn=1::Missing introduction" && exit 1) | |
- name: Check if introduction title is valid | |
run: | | |
jq -e '.introduction | has("title")' _changelog.json || (echo "::error file=CHANGELOG.md,line=1,col=1,endColumn=1::Missing introduction title" && exit 1) | |
TITLE=$(jq -r '.introduction.title' _changelog.json) | |
if [ -z "$TITLE" ] | |
then | |
echo "::error file=CHANGELOG.md,line=1,col=1::Empty introduction title" | |
fi | |
- name: Check if introduction content is valid | |
run: | | |
jq -e '.introduction | has("content")' _changelog.json || (echo "::error file=CHANGELOG.md,line=1,col=1::Missing introduction content" && exit 1) | |
CONTENT=$(jq -r '.introduction.content' _changelog.json) | |
if [ -z "$CONTENT" ] | |
then | |
echo "::error file=CHANGELOG.md,line=1,col=1::Empty introduction content" | |
fi | |
- name: Check length | |
run: | | |
LENGTH=$(jq -r length _changelog.json) | |
if [[ $LENGTH < 2 ]] | |
then | |
echo "::error file=CHANGELOG.md,line=1,col=1::Changelog has not enough releases ($LENGTH), or the Markdown structure is incorrect." | |
error |