diff --git a/.github/workflows/contributors.yml b/.github/workflows/contributors.yml new file mode 100644 index 0000000..6ae05e0 --- /dev/null +++ b/.github/workflows/contributors.yml @@ -0,0 +1,42 @@ +name: Update Contributors + +on: + schedule: + - cron: '0 0 * * *' # Run daily at midnight UTC + workflow_dispatch: # Allow manual trigger + +jobs: + contributors: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + token: ${{ secrets.CONTRIBUTORS_TOKEN }} + + - name: Update contributors + env: + GH_TOKEN: ${{ secrets.CONTRIBUTORS_TOKEN }} + run: | + # Fetch contributors from GitHub API (exclude bots) + contributors=$(gh api repos/CodingWithCalvin/VS-GitRanger/contributors --paginate --jq '.[] | select(.type != "Bot") | select(.login | test("\\[bot\\]$") | not) | "\"\(.login)\"/"') + + # Build the contributors section + contrib_section=" +

+ $contributors +

+ " + + # Update README between the markers + awk -v contrib="$contrib_section" ' + //{found=1; print contrib; next} + //{found=0; next} + !found{print} + ' README.md > README.tmp && mv README.tmp README.md + + - name: Commit and push + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add README.md + git diff --staged --quiet || (git commit -m "docs: update contributors [skip ci]" && git push)