Skip to content

Update Members Wall #68

Update Members Wall

Update Members Wall #68

name: Update Members Wall
on:
workflow_dispatch: # 手动触发
schedule:
- cron: '0 0 * * 1' # 每周一触发
jobs:
update-members:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '21'
- name: Install dependencies
run: |
npm install node-fetch@latest
- name: Generate members list
env:
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}
run: |
node update_members.js
- name: Replace members section in members.md
run: |
readme_content=$(cat _pages/members.md) # 确保路径正确
members_content=$(cat members.md)
echo "$readme_content" | awk -v new_content="$members_content" '
BEGIN { found=0 }
/<!--START_SECTION:members-->/ { print; found=1; next }
/<!--END_SECTION:members-->/ { print new_content; found=0 }
!found { print }
' > _pages/members.md # 确保输出到正确的路径
- name: Check if members.md exists
run: |
if [ -f _pages/members.md ]; then
echo "File _pages/members.md exists."
else
echo "File _pages/members.md does not exist."
exit 1
fi
- name: Commit and Push changes
run: |
git config --global user.name "GitHub Action"
git config --global user.email "[email protected]"
git add _pages/members.md # 确保路径正确
git commit -m "Update members wall in members.md" || echo "No changes to commit"
git push