name: Update contributors on: push: branches: - master pull_request: permissions: contents: write jobs: update_contributors: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 with: repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} # Use the forked repository if available, otherwise the main repository ref: ${{ github.event.pull_request.head.ref || github.ref_name }} # Use the PR branch name if available, otherwise the branch name fetch-depth: 0 # Fetch all history for all branches and tags - name: Install Node.js uses: actions/setup-node@v4 with: node-version: "20" - name: Install dependencies run: npm install axios - name: Update CONTRIBUTORS.md run: | node .github/scripts/update-contributors.js - name: Commit and push if it's not up to date run: | git config --global user.email "actions@github.com" git config --global user.name "GitHub Actions" git checkout -B ${{ github.event.pull_request.head.ref || github.ref_name }} # Ensure we're on the correct branch git diff git commit -am "chore(contributors): Update CONTRIBUTORS.md" || exit 0 git push origin ${{ github.event.pull_request.head.ref || github.ref_name }}