Update Clone Badge #18
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 Clone Badge | |
on: | |
schedule: | |
- cron: '0 0 * * *' # Runs daily | |
workflow_dispatch: # Allows manual triggering | |
jobs: | |
update-badge: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Get clone count | |
id: get_clone_count | |
run: | | |
CLONE_COUNT=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
-s https://api.github.com/repos/Lychan23/Ly.JSxPy \ | |
| jq '.clone_count') | |
echo "CLONE_COUNT=${CLONE_COUNT}" >> $GITHUB_ENV | |
- name: Update Clone Badge in README.md | |
run: | | |
BADGE_URL="https://img.shields.io/badge/Clones-${{ env.CLONE_COUNT }}-blue" | |
# Use sed to replace the badge URL in README.md | |
sed -i "s|https://img.shields.io/badge/Clones-.*-blue|$BADGE_URL|g" README.md | |
- name: Commit and push changes | |
run: | | |
git config --global user.name "github-actions" | |
git config --global user.email "[email protected]" | |
git add README.md | |
git diff --cached --quiet || git commit -m "Update clone count badge" | |
git push | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |