Skip to content

Update Contributors List #639

Update Contributors List

Update Contributors List #639

name: Update Contributors List
on:
# Run every day of the week at 6am and 6pm
schedule:
- cron: '0 6,18 * * *'
# Run if dispatched by @aurora-care-bear using the REST API
repository_dispatch:
# Dispatch if triggered using Github (website)
workflow_dispatch:
jobs:
UpdateContributors:
if: github.repository_owner == 'AuroraEditor'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Create config.json
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "{
\"url\": \"https://api.github.com/users/AuroraEditor/repos\",
\"token\": \"$TOKEN\",
\"exclude\": [
\"ImgBotApp\",
\"aurora-care-bear\",
\"github-actions[bot]\",
\"dependabot[bot]\",
\"allcontributors[bot]\",
\"actions-user\"
]
}" > config.json
- name: Run & Send
run: swift application.swift
- name: Get SHA Hash of contributors.json
id: get_sha
env:
PAT: ${{ secrets.BOT_TOKEN }}
run: |
result=$(curl -s -H "Authorization: Bearer $PAT" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/AuroraEditor/auroraeditor.com/contents/public/data/contributors.json 2>&1)
# Check for errors and log stderr
if [ $? -ne 0 ]; then
echo "::error::Error occurred during curl request:"
echo "::error::$result"
exit 1
fi
# Extract SHA from the JSON response
SHA=$(echo "$result" | jq -r '.sha')
echo "sha=$SHA" >> $GITHUB_OUTPUT
- name: Commit Updated contributors.json to auroraeditor.com Repository
env:
PAT: ${{ secrets.BOT_TOKEN }}
run: |
sha=${{ steps.get_sha.outputs.sha }}
commit_message="Update Contributors"
api_url="https://api.github.com/repos/AuroraEditor/auroraeditor.com/contents/public/data/contributors.json"
json="{\"message\":\"$commit_message\",\"content\":\"$(base64 -i contributors.json -w 0)\",\"branch\":\"main\",\"sha\":\"$sha\"}"
# Use curl to create the commit with the updated JSON file
curl -H "Authorization: Bearer $PAT" -X PUT \
-d "$json" \
"$api_url"
- name: Upload 'contributors.json' to repo
run: |
git config --global user.name 'aurora-care-bear'
git config --global user.email '[email protected]'
git remote set-url --push origin https://aurora-care-bear:[email protected]/AuroraEditor/AEContributorBot
git add contributors.json
git commit --allow-empty -m "Update Contributors (`date`)"
git push origin HEAD:main