hacktoberfest-accepted.yml 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
  2. #
  3. # SPDX-License-Identifier: curl
  4. name: Hacktoberfest
  5. on:
  6. # this must not ever run on any other branch than master
  7. push:
  8. branches:
  9. - master
  10. concurrency:
  11. # this should not run in parallel, so just run one at a time
  12. group: ${{ github.workflow }}
  13. permissions: {}
  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. permissions:
  20. # requires issues AND pull-requests write permissions to edit labels on PRs!
  21. issues: write
  22. pull-requests: write
  23. steps:
  24. - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
  25. with:
  26. fetch-depth: 100
  27. - name: Check whether repo participates in Hacktoberfest
  28. run: |
  29. gh config set prompt disabled && echo "label=$(
  30. gh repo view --json repositoryTopics --jq '.repositoryTopics[].name' | grep '^hacktoberfest$')" >> $GITHUB_OUTPUT
  31. id: check
  32. env:
  33. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  34. - name: Search relevant commit message lines starting with Closes/Merges
  35. run: |
  36. git log --format=email ${{ github.event.before }}..${{ github.event.after }} | \
  37. grep -Ei "^Close[sd]? " | sort | uniq | tee log
  38. if: steps.check.outputs.label == 'hacktoberfest'
  39. - name: Search for Number-based PR references
  40. run: |
  41. grep -Eo "#([0-9]+)" log | cut -d# -f2 | sort | uniq | xargs -t -n1 -I{} \
  42. gh pr view {} --json number,createdAt \
  43. --jq '{number, opened: .createdAt} | [.number, .opened] | join(":")' | tee /dev/stderr | \
  44. grep -Eo '^([0-9]+):[0-9]{4}-(09-30T|10-|11-01T)' | cut -d: -f1 | sort | uniq | xargs -t -n1 -I {} \
  45. gh pr edit {} --add-label 'hacktoberfest-accepted'
  46. if: steps.check.outputs.label == 'hacktoberfest'
  47. env:
  48. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  49. - name: Search for URL-based PR references
  50. run: |
  51. grep -Eo "github.com/(.+)/(.+)/pull/([0-9]+)" log | sort | uniq | xargs -t -n1 -I{} \
  52. gh pr view "https://{}" --json number,createdAt \
  53. --jq '{number, opened: .createdAt} | [.number, .opened] | join(":")' | tee /dev/stderr | \
  54. grep -Eo '^([0-9]+):[0-9]{4}-(09-30T|10-|11-01T)' | cut -d: -f1 | sort | uniq | xargs -t -n1 -I {} \
  55. gh pr edit {} --add-label 'hacktoberfest-accepted'
  56. if: steps.check.outputs.label == 'hacktoberfest'
  57. env:
  58. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}