ci: improve ci #11
This file contains 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: Git Cliff | |
on: | |
pull_request: | |
branches: | |
- master | |
types: | |
- closed | |
workflow_dispatch: | |
jobs: | |
changelog: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Check if PR is merged | |
run: | | |
if [ "${{ github.event.pull_request.merged }}" == "true" ]; then | |
echo "PR is merged, proceeding with changelog update." | |
else | |
echo "PR is not merged, skipping changelog update." | |
exit 0 | |
fi | |
- name: Generate changelog using Git Cliff | |
uses: orhun/git-cliff-action@v4 | |
with: | |
config: cliff.toml | |
args: --verbose | |
env: | |
OUTPUT: CHANGELOG.md | |
GITHUB_REPO: ${{ github.repository }} | |
- name: Commit and push changelog changes | |
run: | | |
git checkout -b changelog-update | |
git config user.name 'github-actions[bot]' | |
git config user.email 'github-actions[bot]@users.noreply.github.com' | |
git add CHANGELOG.md | |
git commit -m "Update changelog" | |
git push https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git changelog-update | |
- name: Create Pull Request | |
run: | | |
gh pr create --base master --head changelog-update --title "Update changelog" --body "This PR updates the changelog based on recent changes." --label bot | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Auto Merge Pull Request | |
run: | | |
gh pr merge --merge --delete-branch --squash "changelog-update" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |