2
0

hacktoberfest-accepted.yml 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. # Copyright (C) 2000 - 2022 Daniel Stenberg, <daniel@haxx.se>, et al.
  2. #
  3. # SPDX-License-Identifier: curl
  4. name: Hacktoberfest
  5. on:
  6. # run for all pushes to master branch
  7. push:
  8. branches:
  9. - master
  10. permissions:
  11. # requires issues AND pull-requests write permissions to edit labels on PRs!
  12. issues: write
  13. pull-requests: write
  14. jobs:
  15. # add hacktoberfest-accepted label to PRs opened starting from September 30th
  16. # till November 1st which are closed via commit reference from master branch.
  17. merged:
  18. runs-on: ubuntu-latest
  19. steps:
  20. - uses: actions/checkout@v3
  21. with:
  22. fetch-depth: 100
  23. - name: Check whether repo participates in Hacktoberfest
  24. run: |
  25. gh config set prompt disabled && echo "::set-output name=label::$(
  26. gh repo view --json repositoryTopics --jq '.repositoryTopics[].name' | grep '^hacktoberfest$')"
  27. id: check
  28. env:
  29. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  30. - name: Search relevant commit message lines starting with Closes/Merges
  31. run: |
  32. git log --format=email ${{ github.event.before }}..${{ github.event.after }} | \
  33. egrep -i "^Close[sd]? " | sort | uniq | tee log
  34. if: steps.check.outputs.label == 'hacktoberfest'
  35. - name: Search for Number-based PR references
  36. run: |
  37. egrep -o "#([0-9]+)" log | cut -d# -f2 | sort | uniq | xargs -t -n1 -I{} \
  38. gh pr view {} --json number,createdAt \
  39. --jq '{number, opened: .createdAt} | [.number, .opened] | join(":")' | tee /dev/stderr | \
  40. egrep -o '^([0-9]+):[0-9]{4}-(09-30T|10-|11-01T)' | cut -d: -f1 | sort | uniq | xargs -t -n1 -I {} \
  41. gh pr edit {} --add-label 'hacktoberfest-accepted'
  42. if: steps.check.outputs.label == 'hacktoberfest'
  43. env:
  44. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  45. - name: Search for URL-based PR references
  46. run: |
  47. egrep -o "github.com/(.+)/(.+)/pull/([0-9]+)" log | sort | uniq | xargs -t -n1 -I{} \
  48. gh pr view "https://{}" --json number,createdAt \
  49. --jq '{number, opened: .createdAt} | [.number, .opened] | join(":")' | tee /dev/stderr | \
  50. egrep -o '^([0-9]+):[0-9]{4}-(09-30T|10-|11-01T)' | cut -d: -f1 | sort | uniq | xargs -t -n1 -I {} \
  51. gh pr edit {} --add-label 'hacktoberfest-accepted'
  52. if: steps.check.outputs.label == 'hacktoberfest'
  53. env:
  54. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}