Skip to content

ci(deps): bump actions/github-script from 8 to 9 #8

ci(deps): bump actions/github-script from 8 to 9

ci(deps): bump actions/github-script from 8 to 9 #8

Workflow file for this run

name: Changelog Validation
on:
pull_request:
paths:
- 'CHANGELOG.md'
- '.github/workflows/changelog.yml'
push:
branches:
- master
paths:
- 'CHANGELOG.md'
jobs:
validate:
name: Validate Changelog Format
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Cache Cargo
uses: actions/cache@v5
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build prodigy
run: cargo build --release
- name: Validate changelog format
run: |
./target/release/prodigy changelog validate CHANGELOG.md --strict
- name: Check for unreleased changes
run: |
if ! grep -q "## \[Unreleased\]" CHANGELOG.md; then
echo "Error: Missing [Unreleased] section in CHANGELOG.md"
exit 1
fi
- name: Validate version links
run: |
# Check that all versions have comparison links at the bottom
VERSIONS=$(grep -oP '## \[\K[0-9]+\.[0-9]+\.[0-9]+(?=\])' CHANGELOG.md)
for VERSION in $VERSIONS; do
if ! grep -q "\[$VERSION\]:" CHANGELOG.md; then
echo "Error: Missing comparison link for version $VERSION"
exit 1
fi
done
check-pr-entry:
name: Check PR Has Changelog Entry
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Check for changelog modification
id: changelog_check
run: |
# Check if CHANGELOG.md was modified in this PR
git fetch origin ${{ github.base_ref }}
if git diff --name-only origin/${{ github.base_ref }}...HEAD | grep -q "CHANGELOG.md"; then
echo "changelog_modified=true" >> $GITHUB_OUTPUT
else
echo "changelog_modified=false" >> $GITHUB_OUTPUT
fi
- name: Check for skip label
id: skip_check
uses: actions/github-script@v9
with:
script: |
const labels = context.payload.pull_request.labels.map(l => l.name);
return labels.includes('skip-changelog');
- name: Require changelog entry
if: steps.changelog_check.outputs.changelog_modified == 'false' && steps.skip_check.outputs.result == 'false'
run: |
echo "Error: This PR does not modify CHANGELOG.md"
echo "Please add an entry to the [Unreleased] section, or add the 'skip-changelog' label if this PR doesn't need a changelog entry."
exit 1
auto-generate:
name: Auto-generate Changelog Preview
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Cache Cargo
uses: actions/cache@v5
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build prodigy
run: cargo build --release
- name: Generate changelog preview
run: |
./target/release/prodigy changelog generate \
--from origin/${{ github.base_ref }} \
--to HEAD \
--output CHANGELOG_PREVIEW.md \
--dry-run > changelog_preview.txt
- name: Comment PR with preview
uses: actions/github-script@v9
with:
script: |
const fs = require('fs');
const preview = fs.readFileSync('changelog_preview.txt', 'utf8');
const body = `## 📝 Changelog Preview\n\n\`\`\`markdown\n${preview}\n\`\`\`\n\n*This preview was automatically generated from conventional commits in this PR.*`;
// Find existing comment
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.data.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('## 📝 Changelog Preview')
);
if (botComment) {
// Update existing comment
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: body
});
} else {
// Create new comment
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body
});
}