Update Members Wall #4
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: Update Member Wall | |
on: | |
schedule: | |
- cron: '0 0 * * 1' # 每周一 UTC 时间 0:00 运行 | |
workflow_dispatch: | |
jobs: | |
update-member-wall: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install jq | |
run: sudo apt-get install jq | |
- name: Get organization members | |
id: get-members | |
run: | | |
members=$(curl -H "Authorization: token ${{ secrets.PAT_TOKEN }}" https://api.github.com/orgs/CompPsyUnion/members) | |
echo "$members" | jq -r '.[] | {login: .login, avatar_url: .avatar_url}' > members.json | |
- name: Generate member wall | |
id: generate-wall | |
run: | | |
logins=$(jq -r '.login' members.json) | |
avatars=$(jq -r '.avatar_url' members.json) | |
echo "# Organization Members" > members.md | |
echo "|:construction_worker:|:construction_worker:|:construction_worker:|:construction_worker:|:construction_worker:|:construction_worker:|" >> members.md | |
echo "|:-------------------:|:-------------------:|:-------------------:|:-------------------:|:-------------------:|:-------------------:|" >> members.md | |
row="" | |
for avatar in $avatars; do | |
row="$row|<img height='48' width='48' src='$avatar'>" | |
if [[ $(echo $row | awk '{print NF-1}') -eq 6 ]]; then | |
echo "$row|" >> members.md | |
row="" | |
fi | |
done | |
if [[ -n "$row" ]]; then | |
echo "$row|" >> members.md | |
fi | |
row="" | |
for login in $logins; do | |
row="$row|[@$login](https://github.com/$login)" | |
if [[ $(echo $row | awk '{print NF-1}') -eq 6 ]]; then | |
echo "$row|" >> members.md | |
row="" | |
fi | |
done | |
if [[ -n "$row" ]]; then | |
echo "$row|" >> members.md | |
fi | |
- name: Configure Git | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
- name: Commit and push changes | |
run: | | |
git add members.md | |
git commit -m "Update members wall" | |
git push |