Skip to content

更新目录结构和提交历史 #3

更新目录结构和提交历史

更新目录结构和提交历史 #3

name: Update Directory Tree
on:
schedule:
- cron: '0 0 * * *' # 每天 UTC 00:00 运行
workflow_dispatch: # 允许手动触发
jobs:
update-directory-tree:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Install tree
run: sudo apt-get install -y tree
- name: Create Directory Tree
run: |
echo "# Personal Notes" > README.md
echo "" >> README.md
echo "## Directory Structure" >> README.md
echo "" >> README.md
echo "\`\`\`" >> README.md
tree -L 2 -I '.git|.github|node_modules' --charset=ascii >> README.md
echo "\`\`\`" >> README.md
- name: Create Pull Request
run: |
# 配置 Git
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
# 创建新分支
current_date=$(date +%Y%m%d_%H%M%S)
branch_name="update-directory-tree-${current_date}"
git checkout -b $branch_name
# 提交更改
git add README.md
git commit -m "docs: update directory tree"
git push origin $branch_name
# 创建 Pull Request
gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}"
gh pr create \
--base master \
--head $branch_name \
--title "docs: update directory tree" \
--body "Automatically update directory tree in README.md" \
--label "documentation"