name: Compile changelog
on:
push:
branches: [main]
paths:
- '.changelog/**'
workflow_dispatch:
permissions:
contents: read
env:
NODE_VERSION: 24
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: false
jobs:
compile:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
timeout-minutes: 5
name: Compile changelog
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
with:
ref: main
fetch-depth: 0
filter: blob:none
persist-credentials: false
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e
with:
node-version: ${{ env.NODE_VERSION }}
package-manager-cache: false
- name: Compile and push
env:
CHANGELOG_TOKEN: ${{ secrets.CHANGELOG_TOKEN }}
GIT_AUTHOR_NAME: github-actions[bot]
GIT_AUTHOR_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com
GIT_COMMITTER_NAME: github-actions[bot]
GIT_COMMITTER_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com
run: |
remote="https://x-access-token:${CHANGELOG_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
for attempt in 1 2 3; do
git fetch --quiet origin main
git reset --quiet --hard origin/main
node ./scripts/changelog.mjs compile
git add --all CHANGELOG.md .changelog
if git diff --cached --quiet; then
echo "There are no fragments to compile."
exit 0
fi
git commit --quiet -m "Compile changelog fragments [skip ci]"
if git push "$remote" HEAD:main; then
exit 0
fi
done
exit 1