update-contributors.yml 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. name: Update Contributors
  2. on:
  3. schedule:
  4. - cron: "0 0 * * *" # Run daily at midnight UTC
  5. workflow_dispatch: # Allow manual trigger
  6. jobs:
  7. update-contributors:
  8. runs-on: ubuntu-latest
  9. steps:
  10. - name: Checkout repository
  11. uses: actions/checkout@v4
  12. with:
  13. token: ${{ secrets.GITHUB_TOKEN }}
  14. - name: Setup pnpm
  15. uses: pnpm/action-setup@v2
  16. with:
  17. version: latest
  18. - name: Setup Node.js
  19. uses: actions/setup-node@v4
  20. with:
  21. node-version: 22
  22. cache: "pnpm"
  23. - name: Install dependencies
  24. run: pnpm install --frozen-lockfile
  25. - name: Update contributors
  26. run: pnpm run update-contributors
  27. - name: Check for changes
  28. id: check
  29. run: |
  30. git diff --quiet README.md || echo "changes=true" >> $GITHUB_OUTPUT
  31. - name: Create Pull Request
  32. if: steps.check.outputs.changes == 'true'
  33. env:
  34. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  35. run: |
  36. # Configure git
  37. git config user.name "github-actions[bot]"
  38. git config user.email "github-actions[bot]@users.noreply.github.com"
  39. # Create a new branch
  40. BRANCH_NAME="update-contributors-${{ github.run_number }}"
  41. git checkout -b "$BRANCH_NAME"
  42. # Commit the changes
  43. git add README.md
  44. git commit -m "chore: update contributors list"
  45. # Push the branch
  46. git push -u origin "$BRANCH_NAME"
  47. # Create the PR using GitHub CLI
  48. gh pr create \
  49. --title "chore: update contributors list" \
  50. --body "## Automated Contributors Update
  51. This PR automatically updates the contributors list based on recent activity.
  52. Generated by the daily contributors update workflow." \
  53. --label "documentation" \
  54. --label "automated" \
  55. --base main \
  56. --head "$BRANCH_NAME"