Skip to content

Commit

Permalink
🐎 ci: TEST
Browse files Browse the repository at this point in the history
  • Loading branch information
Seeridia committed Jun 18, 2023
1 parent dabaeb6 commit 766cb4a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/recent-changes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Recent changes

on:
push:
branches:
- main

jobs:
update_readme:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v2

- name: Update README with recent changes
run: |
# Fetch the latest 3 commits
recent_changes=$(git log -3 --pretty=format:"%h %s" --name-only)
# Extract changed filenames from the recent_changes
changed_files=$(echo "$recent_changes" | grep -P '^(?=\S)(?!\d+\s)' | uniq)
# Format the changed files with numbering
formatted_changes=""
counter=1
while read -r line; do
formatted_changes+="$counter. $line\n"
counter=$((counter+1))
done <<< "$changed_files"
# Update the README.md file
sed -i '/<!-- readme: recent-changes -start -->/,/<!-- readme: recent-changes -end -->/c\<!-- readme: recent-changes -start -->\n'"$formatted_changes"'<!-- readme: recent-changes -end -->' README.md
- name: Commit and push changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add README.md
git commit -m "Update README with recent changes" || echo "No changes to commit"
git push
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
>
> 第四章(有机化学基础)正在进行编写,可能会存在较多错误,而且会出现较频繁更新和大幅修改
## 📄最近改动
<!-- readme: recent-changes -start -->
<!-- readme: recent-changes -end -->

## 📂使用
> 这里是为不熟悉如何使用 Github 的人准备的使用指南
Expand Down

0 comments on commit 766cb4a

Please sign in to comment.