Credit the contributors #92
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: Credit the contributors | |
on: | |
workflow_dispatch: {} | |
schedule: | |
- cron: "0 0 1 * *" | |
env: | |
ORGANIZATION_NAME: "CodeWithAloha" | |
REPOSITORY_NAMES: | | |
( | |
"Hawaii-Zoning-Atlas" | |
"HIERR" | |
"CWAWebsite" | |
) | |
jobs: | |
gather-the-contributors: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v2 | |
# For every contributor to the 'CodeWithAloha' organization, add them to the contributors.json file | |
- name: Query for all contributors for all repositories | |
run: | | |
echo "{\"contributors\": {" > contributors.json | |
array=${{env.REPOSITORY_NAMES}} | |
for item in ${array[@]} | |
do | |
echo " \"$item\": " >> contributors.json | |
contributors=$(curl -s -H "Accept: application/vnd.github+json" https://api.github.com/repos/${{ env.ORGANIZATION_NAME }}/$item/contributors | jq -r '.[] | {username: .login, avatar_url: .avatar_url, url: .html_url }' | jq -s .) | |
for contributor in $contributors | |
do | |
echo $contributor >> contributors.json | |
# " {\"name\": \"$contributor\"}," | |
done | |
sed -i '$ s/.$//' contributors.json | |
echo " ]," >> contributors.json | |
done | |
sed -i '$ s/.$//' contributors.json | |
echo "}}" >> contributors.json | |
cat contributors.json | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version-file: ".nvmrc" | |
- run: npm ci | |
- run: npm run lint | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
commit-message: "[bot] Update contributors.json" | |
title: "[bot] Update contributors.json" | |
branch: "update-contributors-json-bot" |