Skip to content

Commit

Permalink
chore(ci): Separete changelog workflow to manually and automatically (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
anhductn2001 authored Dec 31, 2024
1 parent 8deff6a commit d917094
Showing 1 changed file with 46 additions and 3 deletions.
49 changes: 46 additions & 3 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ on:
- main

jobs:
update_changelog:
update_changelog_auto:
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down Expand Up @@ -50,9 +51,11 @@ jobs:
else
git checkout main
git checkout -b auto-changelog-update-do-not-create-manually
git push origin auto-changelog-update-do-not-create-manually
conventional-changelog -p angular -i CHANGELOG.md -s -r 0
sed -i '1i # Changelog\n## [Unreleased]\n' CHANGELOG.md
git add CHANGELOG.md
git commit -m "Update CHANGELOG.md [skip ci]"
git push origin auto-changelog-update-do-not-create-manually
fi
- name: Create Pull Request
Expand All @@ -78,3 +81,43 @@ jobs:
if: steps.cpr.outputs.pull-request-operation == 'updated'
run: |
echo "Changelog PR updated due to new commit to main."
update_changelog_manually:
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
fetch-depth: 0

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

- name: Configure Git
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Check if "manually-changelog-update" branch exists
id: check_branch
run: |
if [ -n "$(git ls-remote --heads origin manually-changelog-update)" ]; then
git branch -d manually-changelog-update
echo "branch_exists=true" >> $GITHUB_ENV
else
echo "branch_exists=false" >> $GITHUB_ENV
fi
- name: Generate Changelog Update and update if branch exists
run: |
npm install -g conventional-changelog-cli
git checkout -b manually-changelog-update
conventional-changelog -p angular -i CHANGELOG.md -s -r 0
sed -i '1i # Changelog\n## [Unreleased]\n' CHANGELOG.md
git add CHANGELOG.md
git commit -m "Update CHANGELOG.md [skip ci]"
git push origin manually-changelog-update

0 comments on commit d917094

Please sign in to comment.