Skip to content

Commit

Permalink
new flow
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangdv2429 committed May 6, 2024
1 parent 4cdb94f commit 3510931
Showing 1 changed file with 25 additions and 43 deletions.
68 changes: 25 additions & 43 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,61 +1,43 @@
# Creating Pr with following name convention. Common types include feat (a new feature), fix (a bug fix), docs (documentation changes),
# style (formatting, missing semi colons, etc.), refactor (code refactoring), test (adding missing tests),
# chore (changes to the build process or auxiliary tools and libraries such as documentation generation)
# e.g: feat(ci): Add auto generate changelog workflow
name: Changelog Update
name: Auto Changelog Update

on:
pull_request:
push:
branches:
- main
types: [closed]

permissions: write-all

jobs:
update_changelog:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
steps:
- name: Checkout code
- name: Checkout the repository
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.merge_commit_sha }}
fetch-depth: 0 # Ensure all history is fetched

- name: Set up Node.js
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "18"

- name: Install conventional-changelog-cli
run: npm install -g conventional-changelog-cli

- name: Configure Git
run: |
git config user.name 'github-actions'
git config user.email '[email protected]'
- name: Simulate commit for PR title
run: |
echo "${{ github.event.pull_request.title }}" > temp_message.txt
git commit --allow-empty -F temp_message.txt
- name: Generate changelog
run: |
conventional-changelog -p angular -i CHANGELOG.md -s -r 0
node-version: '18'

- name: Show git status and changelog contents
- name: Generate Changelog Update
run: |
git status
echo "Changelog contents:"
cat CHANGELOG.md
# Example: Using conventional-changelog to update CHANGELOG.md
npm install -g conventional-changelog-cli
conventional-changelog -p angular -i CHANGELOG.md -s
- name: Revert temporary commit
run: git reset HEAD~

- name: Commit and push changelog update
- name: Create or Update Pull Request
id: cpr
uses: peter-evans/create-pull-request@v4
with:
# not running ci to save resource on updating changelog
commit-message: "Update CHANGELOG.md [skip ci]"
title: "Automated Changelog Update [skip ci]"
body: "Update the CHANGELOG.md with recent commits. [skip ci]"
branch: auto-changelog-update-${{ github.run_number }}
delete-branch: true
branch-suffix: timestamp

- name: Check if PR needs to be updated
if: steps.cpr.outputs.pull-request-operation == 'updated'
run: |
git add CHANGELOG.md
git diff --staged --quiet || git commit -m "Update CHANGELOG.md based on PR #${{ github.event.pull_request.number }} title"
git push origin HEAD:refs/heads/main
echo "Changelog PR updated due to new commit to main."

0 comments on commit 3510931

Please sign in to comment.