Update Donation Badge #13
This file contains hidden or 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 Donation Badge | |
on: | |
push: | |
paths: | |
- 'donations.json' | |
schedule: | |
- cron: '0 */6 * * *' # Run every 6 hours | |
jobs: | |
update-badge: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: '1.19' | |
- name: Calculate total donations | |
id: total | |
run: | | |
if [ -f donations.json ]; then | |
TOTAL=$(go run ci-donation/calculate-total.go) | |
echo "::set-output name=total::$TOTAL" | |
else | |
echo "::set-output name=total::0" | |
fi | |
- name: Update README badge | |
uses: schneegans/[email protected] | |
with: | |
auth: ${{ secrets.GIST_SECRET }} | |
gistID: your-gist-id | |
filename: total-donations.json | |
label: Total Donations | |
message: Rp ${{ steps.total.outputs.total }} | |
color: blue | |
- name: Commit and push if changed | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add README.md | |
git diff --quiet && git diff --staged --quiet || (git commit -m "Update donation badge" && git push) |