Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Passer1072 committed Nov 8, 2024
2 parents 82356ee + eba1443 commit eecdf26
Show file tree
Hide file tree
Showing 69 changed files with 369 additions and 44,767 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/update-changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Generate Changelog

on:
push:
branches:
- dev
permissions:
contents: write # 允许写入内容

jobs:
generate-changelog:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Git
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
- name: Append to CHANGELOG.md
run: |
CURRENT_DATE=$(date +%Y-%m-%d)
NEW_ENTRIES="- $(git log -1 --pretty=format:"%s (hash: %h)")
# 检查 CHANGELOG.md 中是否存在相同日期的条目
if grep -q "## \[$CURRENT_DATE\] - New Updates" CHANGELOG.md; then
# 存在相同日期的条目,追加新的提交信息
sed -i "/## \[$CURRENT_DATE\] - New Updates/a \n$NEW_ENTRIES" CHANGELOG.md
else
# 不存在相同日期的条目,创建新的条目
HEAD_CONTENT=$(head -n 1 CHANGELOG.md)
TAIL_CONTENT=$(tail -n +2 CHANGELOG.md)
NEW_SECTION="## [$CURRENT_DATE] - New Updates\n$NEW_ENTRIES\n"
echo -e "$HEAD_CONTENT\n$NEW_SECTION$TAIL_CONTENT" > CHANGELOG.md
fi
- name: Display CHANGELOG.md
run: |
cat CHANGELOG.md
- name: Commit and push changes
run: |
git add CHANGELOG.md
git commit -m "Update CHANGELOG.md with new entries" || echo "No changes to commit"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading

0 comments on commit eecdf26

Please sign in to comment.