-
Notifications
You must be signed in to change notification settings - Fork 0
42 lines (36 loc) · 1.42 KB
/
run-contribs.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
name: Update Contributors
on:
schedule:
- cron: "0 0 * * *" # Executa diariamente à meia-noite UTC
workflow_dispatch: # Permite execução manual
jobs:
update-contributors:
runs-on: ubuntu-latest
steps:
- name: Checkout do repositório
uses: actions/checkout@v4
- name: Obter contribuintes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ORG_NAME: "mri-Qbox-Brasil"
run: |
curl -s -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/orgs/$ORG_NAME/repos?per_page=100" | jq -r '.[].name' > repos.txt
contributors=()
for repo in $(cat repos.txt); do
users=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/$ORG_NAME/$repo/contributors?per_page=100" | jq -r '.[].login')
for user in $users; do
if [[ ! " ${contributors[@]} " =~ " $user " ]]; then
contributors+=($user)
fi
done
done
printf '%s\n' "${contributors[@]}" | jq -R . | jq -s . > public/contributors.json
- name: Commit e push
run: |
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
git add public/contributors.json
git commit -m "Atualização da lista de contribuintes" || exit 0
git push