Update Contributors #3
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 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 |