Update ChangeLogs #117
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0 | |
| with: | |
| egress-policy: audit | |
| - name: Checkout repository (Full history) | |
| uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 | |
| 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@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.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@98357b18bf14b5342f975ff684046ec3b2a07725 # v8.0.0 | |
| 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 }}." |