Skip to content

build(deps-dev): bump markdownlint-cli2 from 0.23.1 to 0.23.2 #357

build(deps-dev): bump markdownlint-cli2 from 0.23.1 to 0.23.2

build(deps-dev): bump markdownlint-cli2 from 0.23.1 to 0.23.2 #357

name: Changelog • Management
on:
pull_request:
branches: [develop]
types: [opened, synchronize, reopened, edited, ready_for_review, closed]
paths-ignore:
- "docs/**"
- "**.md"
workflow_call:
inputs:
validate_only:
description: "Run only validation without sync/commit"
required: false
default: false
type: boolean
concurrency:
group: changelog-mgmt-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: read
jobs:
# Job 1: Validate changelog on PR
validate-changelog:
name: Validate changelog on PR
if: github.event_name == 'pull_request' && github.event.action != 'closed' && github.actor != 'imgbot[bot]'
runs-on: ubuntu-latest
outputs:
should_sync: ${{ steps.gate.outputs.run_validation }}
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
persist-credentials: false
- name: Require changelog update or skip label
id: gate
uses: actions/github-script@v7
with:
script: |
const cp = require("node:child_process");
const author = context.payload.pull_request?.user?.login || "";
const labels = (context.payload.pull_request?.labels || []).map((l) => l.name);
const has = (name) => labels.includes(name);
if (author === "dependabot[bot]" || author === "app/dependabot") {
core.info("Skipping changelog requirement for Dependabot pull requests.");
core.setOutput("run_validation", "false");
return;
}
if (has("meta:needs-changelog") && has("meta:no-changelog")) {
core.setFailed("PR cannot include both meta:needs-changelog and meta:no-changelog.");
return;
}
const restrictedTypes = new Set([
"type:feature",
"type:bug",
"type:performance",
"type:security",
"type:release",
"type:hotfix",
]);
if (has("meta:no-changelog") && labels.some((label) => restrictedTypes.has(label))) {
core.setFailed("meta:no-changelog is not allowed for high-impact release-related change types.");
return;
}
const baseSha = context.payload.pull_request?.base?.sha;
const headSha = context.payload.pull_request?.head?.sha;
const changed = cp
.execSync(`git diff --name-only ${baseSha} ${headSha}`, {
encoding: "utf8",
maxBuffer: 1024 * 1024 * 100,
})
.split("\n")
.filter(Boolean);
if (changed.includes("CHANGELOG.md")) {
core.info("CHANGELOG.md updated in PR diff.");
core.setOutput("run_validation", "true");
return;
}
if (has("meta:no-changelog")) {
core.info("Skipping changelog requirement due to meta:no-changelog label.");
core.setOutput("run_validation", "false");
return;
}
core.setFailed("PR requires a CHANGELOG.md update or the meta:no-changelog label.");
- name: Setup Node
uses: actions/setup-node@v7
with:
node-version-file: ".nvmrc"
- name: Validate changelog schema
if: steps.gate.outputs.run_validation == 'true'
run: |
node .github/scripts/agents/includes/changelogUtils.cjs --validate CHANGELOG.md
node .github/scripts/validation/validate-changelog.cjs CHANGELOG.md
# Job 2: Sync changelog on merge to develop
sync-changelog:
name: Auto-sync merged changelog entries
if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: read
steps:
- name: Checkout develop
uses: actions/checkout@v7
with:
ref: develop
fetch-depth: 0
- name: Check if CHANGELOG.md was modified
id: check_changelog
uses: actions/github-script@v7
with:
script: |
const { data: files } = await github.rest.pulls.listFiles({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
});
const hasChangelog = files.some(f => f.filename === 'CHANGELOG.md');
core.setOutput('has_changelog', hasChangelog);
- name: Setup Node.js
if: steps.check_changelog.outputs.has_changelog == 'true'
uses: actions/setup-node@v7
with:
node-version-file: ".nvmrc"
- name: Install dependencies
if: steps.check_changelog.outputs.has_changelog == 'true'
run: npm ci --ignore-scripts
- name: Extract PR changelog entries
id: extract
if: steps.check_changelog.outputs.has_changelog == 'true'
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
CHANGELOG_PATH: CHANGELOG.md
run: |
set -euo pipefail
node .github/scripts/workflows/changelog/extract-pr-entries.cjs
- name: Validate extracted entries
if: steps.extract.outputs.has_entries == 'true'
run: |
node .github/scripts/agents/includes/changelogUtils.cjs --validate CHANGELOG.md
- name: Merge changelog entries
if: steps.extract.outputs.has_entries == 'true'
env:
PR_ENTRIES: ${{ steps.extract.outputs.entries_file }}
CHANGELOG_PATH: CHANGELOG.md
run: |
set -euo pipefail
node .github/scripts/workflows/changelog/merge-entries.cjs
- name: Validate final changelog schema
if: steps.extract.outputs.has_entries == 'true'
run: |
node .github/scripts/validation/validate-changelog.cjs CHANGELOG.md
- name: Commit changelog update
if: steps.extract.outputs.has_entries == 'true'
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
git config user.name "lightspeed-bot"
git config user.email "ops@lightspeedwp.agency"
git add CHANGELOG.md
if ! git diff --cached --quiet; then
git commit -m "chore(changelog): merge entries from PR #${PR_NUMBER} [skip ci]"
git push origin develop
fi
- name: Report action
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
HAS_ENTRIES: ${{ steps.extract.outputs.has_entries }}
run: bash scripts/report-changelog-action.sh
# Job 3: Pre-release validation check (called from release.yml)
pre-release-check:
name: Pre-release changelog validation
if: github.event_name == 'workflow_call'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
persist-credentials: false
- name: Setup Node
uses: actions/setup-node@v7
with:
node-version-file: ".nvmrc"
- name: Validate changelog for release
run: |
node .github/scripts/agents/includes/changelogUtils.cjs --validate CHANGELOG.md
node .github/scripts/validation/validate-changelog.cjs CHANGELOG.md
- name: Check for unreleased section
run: |
if grep -q "## \[Unreleased\]" CHANGELOG.md; then
echo "✅ Changelog has Unreleased section"
else
echo "⚠️ Warning: No Unreleased section found in CHANGELOG.md"
fi