Skip to content

Commit

Permalink
chores(ci): add new changelog gen workflow (#863)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangdv2429 authored May 20, 2024
1 parent c9d2d23 commit d907bc8
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 4 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Auto Changelog Update

on:
push:
branches:
- main

jobs:
update_changelog:
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v3
with:
fetch-depth: 1

- 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 "auto-changelog-update-do-not-create-manually" branch exists
id: check_branch
run: |
if [ -n "$(git ls-remote --heads origin auto-changelog-update-do-not-create-manually)" ]; then
git fetch origin auto-changelog-update-do-not-create-manually
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
if [ "$branch_exists" == "true" ]; then
git checkout auto-changelog-update-do-not-create-manually
git merge main --strategy-option theirs --allow-unrelated-histories --no-edit
conventional-changelog -p angular -i CHANGELOG.md -s -r 0 --append
git add CHANGELOG.md
git commit -m "Update CHANGELOG.md [skip ci]"
git push origin auto-changelog-update-do-not-create-manually
exit 0
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 --append
fi
- name: Create Pull Request
if: env.branch_exists == 'false'
id: cpr
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Update CHANGELOG.md [skip ci]"
title: "Chore(changelog): Automated Changelog Update [skip ci]"
body: "Update the CHANGELOG.md with recent pushes to branch main."
base: "main"
branch: "auto-changelog-update-do-not-create-manually"
delete-branch: true

- name: Check outputs
if: env.branch_exists == 'false'
run: |
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
- name: Log if PR updated
if: steps.cpr.outputs.pull-request-operation == 'updated'
run: |
echo "Changelog PR updated due to new commit to main."
2 changes: 1 addition & 1 deletion .github/workflows/markdown_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
uses: nosborn/[email protected]
with:
files: ./
config_file: .markdownlint.yaml
config_file: .markdownlint.yaml
2 changes: 0 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ issues:
- "^.*SA1019.*$" # Excluding SA1019 errors

linters-settings:
go-version-checker:
min-version: "1.22"
revive:
rules:
- name: exported
Expand Down
1 change: 1 addition & 0 deletions .markdownlintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CHANGELOG.md
2 changes: 1 addition & 1 deletion contrib/githooks/pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,6 @@ repos:
hooks:
- id: validate-toml
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.34.0
rev: v0.39.0
hooks:
- id: markdownlint

0 comments on commit d907bc8

Please sign in to comment.