Skip to content

Update Clone Badge

Update Clone Badge #15

Workflow file for this run

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 }}