|
| 1 | +name: allcontributors-auto-detect |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # Run nightly 1am |
| 6 | + - cron: 0 1 * * * |
| 7 | + |
| 8 | + # You can also have it check for changes on each push to master |
| 9 | + push: |
| 10 | + branches: |
| 11 | + - main |
| 12 | + - dev |
| 13 | + |
| 14 | +jobs: |
| 15 | + Update: |
| 16 | + name: Generate |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - name: Checkout Repository |
| 20 | + uses: actions/checkout@v2 |
| 21 | + - name: Tributors Update |
| 22 | + |
| 23 | + # Important! Update to release https://github.com/con/tributors |
| 24 | + uses: con/tributors@master |
| 25 | + env: |
| 26 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 27 | + with: |
| 28 | + |
| 29 | + # Single text list (space separated) of parsers, leave unset to auto-detect |
| 30 | + parsers: unset |
| 31 | + |
| 32 | + # INFO, DEBUG, ERROR, WARNING, etc. |
| 33 | + log_level: DEBUG |
| 34 | + |
| 35 | + # If files already exist and an init is done, force overwrite |
| 36 | + force: true |
| 37 | + |
| 38 | + # the minimum number of contributions required to add a user |
| 39 | + threshold: 1 |
| 40 | + |
| 41 | + - name: Checkout New Branch |
| 42 | + env: |
| 43 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 44 | + BRANCH_AGAINST: "main" |
| 45 | + run: | |
| 46 | + printf "GitHub Actor: ${GITHUB_ACTOR}\n" |
| 47 | + export BRANCH_FROM="contributors/update-$(date '+%Y-%m-%d')" |
| 48 | + git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" |
| 49 | +
|
| 50 | + BRANCH_EXISTS=$(git ls-remote --heads origin ${BRANCH_FROM}) |
| 51 | + if [[ -z ${BRANCH_EXISTS} ]]; then |
| 52 | + printf "Branch does not exist in remote.\n" |
| 53 | + else |
| 54 | + printf "Branch already exists in remote.\n" |
| 55 | + exit 1 |
| 56 | + fi |
| 57 | + git branch |
| 58 | + git checkout -b "${BRANCH_FROM}" || git checkout "${BRANCH_FROM}" |
| 59 | + git branch |
| 60 | +
|
| 61 | + git config --global user.name "github-actions" |
| 62 | + git config --global user.email "[email protected]" |
| 63 | +
|
| 64 | + git status |
| 65 | +
|
| 66 | + # Make sure to add new files or path/* |
| 67 | + git add .tributors |
| 68 | + git add README.md |
| 69 | + git add .all-contributorsrc |
| 70 | +
|
| 71 | + if git diff-index --quiet HEAD --; then |
| 72 | + export OPEN_PULL_REQUEST=0 |
| 73 | + printf "No changes\n" |
| 74 | + else |
| 75 | + export OPEN_PULL_REQUEST=1 |
| 76 | + printf "Changes\n" |
| 77 | + git commit -a -m "Automated deployment to update contributors $(date '+%Y-%m-%d')" |
| 78 | + git push origin "${BRANCH_FROM}" |
| 79 | + fi |
| 80 | + echo "::set-env name=OPEN_PULL_REQUEST::${OPEN_PULL_REQUEST}" |
| 81 | + echo "::set-env name=PULL_REQUEST_FROM_BRANCH::${BRANCH_FROM}" |
| 82 | + echo "::set-env name=PULL_REQUEST_TITLE::[tributors] ${BRANCH_FROM}" |
| 83 | + echo "::set-env name=PULL_REQUEST_BODY::Updating tributors automated pull request." |
| 84 | +
|
| 85 | + - name: Open Pull Request |
| 86 | + |
| 87 | + if: ${{ env.OPEN_PULL_REQUEST == '1' }} |
| 88 | + env: |
| 89 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 90 | + PULL_REQUEST_BRANCH: "master" |
0 commit comments