Skip to content

Update ChangeLogs

Update ChangeLogs #113

name: Update ChangeLogs
on:
workflow_dispatch:
workflow_run:
workflows: ["Publish"]
types:
- completed
concurrency:
group: update-changelogs-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
pull-requests: write
actions: write
checks: write
issues: write
statuses: write
jobs:
update_changelogs:
runs-on: windows-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
with:
egress-policy: audit
- name: Checkout repository (Full history)
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
fetch-depth: 0
- name: Create Check Run
id: create_check
env:
GH_TOKEN: ${{ github.token }}
shell: pwsh
run: |
$checkId = gh api -X POST -H "Accept: application/vnd.github+json" `
-H "X-GitHub-Api-Version: 2022-11-28" `
-f name='Update ChangeLogs' `
-f head_sha='${{ github.sha }}' `
-f status='in_progress' `
-f 'output[title]=Update ChangeLogs' `
-f 'output[summary]=Changelog update in progress' `
--jq '.id' `
/repos/${{ github.repository }}/check-runs
echo "CHECKID=$checkId" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Set up Node.js
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
with:
node-version: "20"
- name: Install git-cliff
shell: pwsh
run: npm install -g git-cliff
- name: Generate CHANGELOG.md files (With verbose logging)
shell: pwsh
run: |
echo "Generating changelogs with git-cliff..."
npx git-cliff --config cliff.toml --verbose --output CHANGELOG.md
Get-ChildItem -Name
- name: Create Pull Request for changelogs
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
with:
commit-message: "chore: update changelogs [skip ci]"
title: "chore: update changelogs"
body: "Automated changelog update via GitHub Actions.\n\nThis PR was created automatically and will not be merged automatically."
branch: "chore/update-changelogs"
add-paths: "**/CHANGELOG.md"
delete-branch: false
token: ${{ secrets.GITHUB_TOKEN }}
- name: Update Check Run - Changelogs Generated
if: success()
env:
GH_TOKEN: ${{ github.token }}
shell: pwsh
run: |
$body = @'
{
"status": "in_progress",
"output": {
"title": "Update ChangeLogs",
"summary": "Changelogs generated. Creating PR..."
}
}
'@
$body | gh api -X PATCH -H "Accept: application/vnd.github+json" `
-H "X-GitHub-Api-Version: 2022-11-28" `
/repos/${{ github.repository }}/check-runs/$env:CHECKID --input -
- name: Complete Check Run
if: always()
env:
GH_TOKEN: ${{ github.token }}
shell: pwsh
run: |
$body = @'
{
"conclusion": "success",
"output": {
"title": "Update ChangeLogs",
"summary": "Changelog update workflow completed successfully."
}
}
'@
$body | gh api -X PATCH -H "Accept: application/vnd.github+json" `
-H "X-GitHub-Api-Version: 2022-11-28" `
/repos/${{ github.repository }}/check-runs/$env:CHECKID --input -
- name: Add Job Summary
if: always()
shell: pwsh
run: |
Add-Content -Path $env:GITHUB_STEP_SUMMARY "## 📝 Changelog Update Workflow Summary"
Add-Content -Path $env:GITHUB_STEP_SUMMARY "- CHANGELOG.md files were generated or updated in the repository and subfolders."
Add-Content -Path $env:GITHUB_STEP_SUMMARY "- A pull request was created or updated with the new changelogs."
Add-Content -Path $env:GITHUB_STEP_SUMMARY "- Check runs were updated to reflect the workflow status."
Add-Content -Path $env:GITHUB_STEP_SUMMARY "- Workflow completed with status: ${{ job.status }}."