Skip to content

Commit 4aaa8e8

Browse files
authored
chore(ci): add contributors workflow (#39)
Adds nightly workflow to auto-update README contributors section
1 parent 9b1626f commit 4aaa8e8

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

.github/workflows/contributors.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Update Contributors
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *' # Run daily at midnight UTC
6+
workflow_dispatch: # Allow manual trigger
7+
8+
jobs:
9+
contributors:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
token: ${{ secrets.CONTRIBUTORS_TOKEN }}
15+
16+
- name: Update contributors
17+
env:
18+
GH_TOKEN: ${{ secrets.CONTRIBUTORS_TOKEN }}
19+
run: |
20+
# Fetch contributors from GitHub API (exclude bots)
21+
contributors=$(gh api repos/CodingWithCalvin/VS-GitRanger/contributors --paginate --jq '.[] | select(.type != "Bot") | select(.login | test("\\[bot\\]$") | not) | "<a href=\"\(.html_url)\"><img src=\"\(.avatar_url)\" width=\"64\" height=\"64\" alt=\"\(.login)\"/></a>"')
22+
23+
# Build the contributors section
24+
contrib_section="<!-- readme: contributors -start -->
25+
<p align=\"left\">
26+
$contributors
27+
</p>
28+
<!-- readme: contributors -end -->"
29+
30+
# Update README between the markers
31+
awk -v contrib="$contrib_section" '
32+
/<!-- readme: contributors -start -->/{found=1; print contrib; next}
33+
/<!-- readme: contributors -end -->/{found=0; next}
34+
!found{print}
35+
' README.md > README.tmp && mv README.tmp README.md
36+
37+
- name: Commit and push
38+
run: |
39+
git config user.name "github-actions[bot]"
40+
git config user.email "github-actions[bot]@users.noreply.github.com"
41+
git add README.md
42+
git diff --staged --quiet || (git commit -m "docs: update contributors [skip ci]" && git push)

0 commit comments

Comments
 (0)