mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 14:45:49 +01:00
Update changelog-validation-v3.yml
This commit is contained in:
parent
c08d2d72c3
commit
9f2b992d36
1 changed files with 16 additions and 66 deletions
82
.github/workflows/changelog-validation-v3.yml
vendored
82
.github/workflows/changelog-validation-v3.yml
vendored
|
|
@ -3,8 +3,6 @@ name: Changelog Validation (v3)
|
|||
on:
|
||||
pull_request:
|
||||
branches: [ v3-alpha ]
|
||||
paths:
|
||||
- 'docs/src/content/docs/changelog.mdx'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
pr_number:
|
||||
|
|
@ -49,76 +47,28 @@ jobs:
|
|||
id: changelog_check
|
||||
run: |
|
||||
git fetch origin ${{ steps.pr_info.outputs.base_ref }}
|
||||
if git diff --name-only origin/${{ steps.pr_info.outputs.base_ref }}..HEAD | grep -q "docs/src/content/docs/changelog.mdx"; then
|
||||
if git diff --name-only origin/${{ steps.pr_info.outputs.base_ref }}..HEAD | grep -q "v3/UNRELEASED_CHANGELOG.md"; then
|
||||
echo "changelog_modified=true" >> $GITHUB_OUTPUT
|
||||
echo "✅ Changelog was modified in this PR"
|
||||
echo "✅ UNRELEASED_CHANGELOG.md was modified in this PR"
|
||||
else
|
||||
echo "changelog_modified=false" >> $GITHUB_OUTPUT
|
||||
echo "ℹ️ Changelog was not modified - skipping validation"
|
||||
echo "⚠️ UNRELEASED_CHANGELOG.md was not modified"
|
||||
fi
|
||||
|
||||
- name: Get changelog diff
|
||||
id: get_diff
|
||||
if: steps.changelog_check.outputs.changelog_modified == 'true'
|
||||
run: |
|
||||
git fetch origin ${{ steps.pr_info.outputs.base_ref }}
|
||||
git diff origin/${{ steps.pr_info.outputs.base_ref }}..HEAD docs/src/content/docs/changelog.mdx | grep "^+" | grep -v "^+++" | sed 's/^+//' > /tmp/pr_added_lines.txt
|
||||
echo "Lines added in this PR:"
|
||||
cat /tmp/pr_added_lines.txt
|
||||
|
||||
- name: Validate changelog entries
|
||||
id: validate
|
||||
if: steps.changelog_check.outputs.changelog_modified == 'true'
|
||||
run: |
|
||||
cd v3/scripts
|
||||
OUTPUT=$(go run validate-changelog.go ../../docs/src/content/docs/changelog.mdx /tmp/pr_added_lines.txt 2>&1)
|
||||
echo "$OUTPUT"
|
||||
RESULT=$(echo "$OUTPUT" | grep "VALIDATION_RESULT=" | cut -d'=' -f2)
|
||||
echo "result=$RESULT" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Commit fixes if needed
|
||||
id: commit_changes
|
||||
if: steps.validate.outputs.result == 'fixed'
|
||||
run: |
|
||||
git config --local user.email "action@github.com"
|
||||
git config --local user.name "GitHub Action"
|
||||
if git diff --quiet docs/src/content/docs/changelog.mdx; then
|
||||
echo "committed=false" >> $GITHUB_OUTPUT
|
||||
else
|
||||
git add docs/src/content/docs/changelog.mdx
|
||||
git commit -m "🤖 Fix changelog: move entries to Unreleased section"
|
||||
git push origin HEAD
|
||||
echo "committed=true" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Comment on PR
|
||||
if: steps.validate.outputs.result && github.event_name == 'pull_request'
|
||||
- name: Comment on PR about missing changelog
|
||||
if: steps.changelog_check.outputs.changelog_modified == 'false' && github.event_name == 'pull_request'
|
||||
uses: actions/github-script@v7
|
||||
with:
|
||||
script: |
|
||||
const result = '${{ steps.validate.outputs.result }}';
|
||||
const committed = '${{ steps.commit_changes.outputs.committed }}';
|
||||
let message;
|
||||
const author = context.payload.pull_request.user.login;
|
||||
const message = '## ⚠️ Missing Changelog Update\n\n' +
|
||||
`Hi @${author}, please update \`v3/UNRELEASED_CHANGELOG.md\` with a description of your changes.\n\n` +
|
||||
'This helps us keep track of changes for the next release.';
|
||||
|
||||
if (result === 'success') {
|
||||
message = '## ✅ Changelog Validation Passed\n\nNo misplaced changelog entries detected.';
|
||||
} else if (result === 'fixed' && committed === 'true') {
|
||||
message = '## 🔧 Changelog Updated\n\nMisplaced entries were automatically moved to the `[Unreleased]` section.';
|
||||
} else if (result === 'cannot_fix' || result === 'error') {
|
||||
message = '## ❌ Changelog Validation Failed\n\nPlease manually move changelog entries to the `[Unreleased]` section.';
|
||||
}
|
||||
|
||||
if (message) {
|
||||
await github.rest.issues.createComment({
|
||||
issue_number: ${{ steps.pr_info.outputs.pr_number }},
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: message
|
||||
});
|
||||
}
|
||||
|
||||
- name: Fail if validation failed
|
||||
if: steps.validate.outputs.result == 'cannot_fix' || steps.validate.outputs.result == 'error'
|
||||
run: |
|
||||
echo "❌ Changelog validation failed"
|
||||
exit 1
|
||||
await github.rest.issues.createComment({
|
||||
issue_number: ${{ steps.pr_info.outputs.pr_number }},
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: message
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue