Create clone-count.yml #1
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
#used chatgpt for this lol | |
name: Clone Count | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
push: | |
branches: | |
- main | |
jobs: | |
update-clone-count: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Fetch clone count | |
run: | | |
CLONE_COUNT=$(curl -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
https://api.github.com/repos/${{ github.repository }}/traffic/clones \ | |
| jq '.count') | |
echo "clone_count=${CLONE_COUNT}" >> $GITHUB_ENV | |
- name: Update badge | |
run: | | |
curl -o clone-count-badge.svg "https://img.shields.io/badge/Clones-${{ env.clone_count }}-brightgreen" | |
git config --global user.name 'github-actions' | |
git config --global user.email 'github-actions@github.com' | |
git add clone-count-badge.svg | |
git commit -m "Update clone count badge" | |
git push |