diff --git a/.github/workflows/update-contributors.yml b/.github/workflows/update-contributors.yml new file mode 100644 index 0000000..401e744 --- /dev/null +++ b/.github/workflows/update-contributors.yml @@ -0,0 +1,39 @@ +name: Update Contributors in README + +on: + push: + branches: + - main + +jobs: + update-contributors: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Install GitHub CLI + run: | + sudo apt-get install gh + + - name: Fetch contributors + id: get_contributors + run: | + CONTRIBUTORS=$(gh api repos/${{ github.repository }}/contributors --jq '.[].login' | tr '\n' ', ') + echo "CONTRIBUTORS=${CONTRIBUTORS}" >> $GITHUB_ENV + + - name: Update README + run: | + echo "## Contributors" >> README.md + echo "${{ env.CONTRIBUTORS }}" >> README.md + + - name: Commit changes + run: | + git config --local user.name "GitHub Action" + git config --local user.email "action@github.com" + git add README.md + git commit -m "Update README with contributors" || echo "No changes to commit" + git push + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}