Update MoeCounter #41
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 MoeCounter | |
on: | |
schedule: | |
- cron: "0 0 * * 0" | |
workflow_dispatch: | |
jobs: | |
update-counter: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Go | |
uses: actions/setup-go@v5.0.2 | |
- name: Get binary count | |
id: get-listc | |
run: | | |
# First attempt to get the count | |
LISTC=$(go run *.go list | wc -l) | |
echo "LISTC=$LISTC" >> $GITHUB_ENV | |
# If the count is 0, wait 90 seconds and try again | |
if [ "$LISTC" -eq 0 ]; then | |
echo "First attempt returned 0, waiting 90 seconds..." | |
sleep 90 | |
LISTC=$(go run *.go list | wc -l) | |
echo "LISTC after retry=$LISTC" >> $GITHUB_ENV | |
fi | |
# If still 0 after retry, fail the job | |
if [ "$LISTC" -eq 0 ]; then | |
echo "ERROR: The count is still 0 after retrying. Exiting without updating counter." | |
exit 1 | |
fi | |
- name: Download MoeCounter image | |
run: | | |
wget -O ./misc/assets/counter.svg \ | |
"https://api.sefinek.net/api/v2/moecounter?number=${{ env.LISTC }}&length=5&theme=gelbooru&pixelated=true" | |
- name: Commit and push updated counter image | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git add ./misc/assets/counter.svg | |
git commit -m "[WEEKLY] Update MoeCounter image" | |
git push |