update-contributors.yml 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. name: allcontributors-auto-detect
  2. on:
  3. push:
  4. branches:
  5. - main
  6. jobs:
  7. Update:
  8. name: Generate
  9. runs-on: ubuntu-latest
  10. if: contains(github.repository, 'datalad/datalad-gooey')
  11. steps:
  12. - name: Checkout Repository
  13. uses: actions/checkout@v2
  14. - name: Tributors Update
  15. uses: con/tributors@0.0.21
  16. env:
  17. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  18. with:
  19. # Single text list (space separated) of parsers, leave unset to auto-detect
  20. parsers: unset
  21. # Update lookup with GitHub metadata
  22. update_lookup: github
  23. # Skip these users (example)
  24. #skip_users: manbat bhanuprasad14 yetanothertestuser bobknob23987
  25. # INFO, DEBUG, ERROR, WARNING, etc.
  26. log_level: DEBUG
  27. # If files already exist and an init is done, force overwrite
  28. force: true
  29. # the minimum number of contributions required to add a user
  30. threshold: 1
  31. - name: Checkout New Branch
  32. env:
  33. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  34. BRANCH_AGAINST: "main"
  35. run: |
  36. printf "GitHub Actor: ${GITHUB_ACTOR}\n"
  37. export BRANCH_FROM="contributors/update-$(date '+%Y-%m-%d')"
  38. git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
  39. BRANCH_EXISTS=$(git ls-remote --heads origin ${BRANCH_FROM})
  40. if [[ -z ${BRANCH_EXISTS} ]]; then
  41. printf "Branch does not exist in remote.\n"
  42. else
  43. printf "Branch already exists in remote.\n"
  44. exit 1
  45. fi
  46. git branch
  47. git checkout -b "${BRANCH_FROM}" || git checkout "${BRANCH_FROM}"
  48. git branch
  49. git config --global user.name "github-actions"
  50. git config --global user.email "github-actions@users.noreply.github.com"
  51. git status
  52. if git diff-index --quiet HEAD --; then
  53. export OPEN_PULL_REQUEST=0
  54. printf "No changes\n"
  55. else
  56. export OPEN_PULL_REQUEST=1
  57. printf "Changes\n"
  58. git commit -a -m "Automated deployment to update contributors $(date '+%Y-%m-%d')
  59. [skip ci]"
  60. git push origin "${BRANCH_FROM}"
  61. fi
  62. echo "OPEN_PULL_REQUEST=${OPEN_PULL_REQUEST}" >> $GITHUB_ENV
  63. echo "PULL_REQUEST_FROM_BRANCH=${BRANCH_FROM}" >> $GITHUB_ENV
  64. echo "PULL_REQUEST_TITLE=[tributors] ${BRANCH_FROM}" >> $GITHUB_ENV
  65. echo "PULL_REQUEST_BODY='Tributors update automated pull request.\n\n[skip ci]'" >> $GITHUB_ENV
  66. - name: Open Pull Request
  67. uses: vsoch/pull-request-action@1.0.17
  68. if: ${{ env.OPEN_PULL_REQUEST == '1' }}
  69. env:
  70. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  71. PULL_REQUEST_BRANCH: "main"