diff --git a/.github/workflows/clone-count.yml b/.github/workflows/clone-count.yml new file mode 100644 index 0000000..81d74a3 --- /dev/null +++ b/.github/workflows/clone-count.yml @@ -0,0 +1,35 @@ +#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