Skip to content

Commit f4f60e9

Browse files
committed
try manual trigger again
1 parent 70040d5 commit f4f60e9

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

.github/workflows/contributors.yml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
- 4-proj-automatically-generate-a-contributors-list-in-maintainersmd-file
6+
workflow_dispatch:
7+
8+
jobs:
9+
update-contributors:
10+
runs-on: ubuntu-latest
11+
name: Update contributors info in MAINTAINERS.md
12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
steps:
16+
# Update contributor list
17+
- name: Contribute List
18+
uses: akhilmhdh/[email protected]
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
with:
22+
# https://github.com/marketplace/actions/contribute-list#optional-parameters
23+
readme_path: MAINTAINERS.md
24+
use_username: false
25+
commit_message: "BOT: Update contributors info in MAINTAINERS.md"
26+
27+
# Update contributor count
28+
- name: Checkout repository
29+
uses: actions/checkout@v4
30+
31+
- name: Get repository contributors count
32+
id: get_contributors
33+
run: |
34+
REPO_OWNER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f1)
35+
REPO_NAME=$(echo $GITHUB_REPOSITORY | cut -d'/' -f2)
36+
CONTRIBUTORS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/contributors?per_page=100" | jq '. | length')
37+
echo "Total contributors: $CONTRIBUTORS"
38+
echo "contributors=$CONTRIBUTORS" >> $GITHUB_OUTPUT
39+
40+
- name: Replace slug in MAINTAINERS.md with number of contributors
41+
run: |
42+
CONTRIBUTORS=${{ steps.get_contributors.outputs.contributors }}
43+
sed -i 's/<!--CONTRIBUTOR COUNT START-->.*<!--CONTRIBUTOR COUNT END-->/<!--CONTRIBUTOR COUNT START--> '"$CONTRIBUTORS"' <!--CONTRIBUTOR COUNT END-->/g' MAINTAINERS.md
44+
45+
- name: Commit and push changes
46+
# commit changes, but if no changes exist, then exit cleanly
47+
run: |
48+
git config user.name 'github-actions[bot]'
49+
git config user.email 'github-actions[bot]@users.noreply.github.com'
50+
git add MAINTAINERS.md
51+
git commit -m "BOT: Update contributors info in MAINTAINERS.md" || exit 0
52+
git push

0 commit comments

Comments
 (0)