hacktoberfest-accepted.yml 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
  25. with:
  26. persist-credentials: false
  27. fetch-depth: 100
  28. - name: Check whether repo participates in Hacktoberfest
  29. run: |
  30. gh config set prompt disabled && echo "label=$(
  31. gh repo view --json repositoryTopics --jq '.repositoryTopics[].name' | grep '^hacktoberfest$')" >> $GITHUB_OUTPUT
  32. id: check
  33. env:
  34. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  35. - name: Search relevant commit message lines starting with Closes/Merges
  36. run: |
  37. git log --format=email '${{ github.event.before }}..${{ github.event.after }}' | \
  38. grep -Ei '^Close[sd]? ' | sort | uniq | tee log
  39. if: steps.check.outputs.label == 'hacktoberfest'
  40. - name: Search for Number-based PR references
  41. run: |
  42. grep -Eo '#([0-9]+)' log | cut -d# -f2 | sort | uniq | xargs -t -n1 -I{} \
  43. gh pr view {} --json number,createdAt \
  44. --jq '{number, opened: .createdAt} | [.number, .opened] | join(":")' | tee /dev/stderr | \
  45. grep -Eo '^([0-9]+):[0-9]{4}-(09-30T|10-|11-01T)' | cut -d: -f1 | sort | uniq | xargs -t -n1 -I {} \
  46. gh pr edit {} --add-label 'hacktoberfest-accepted'
  47. if: steps.check.outputs.label == 'hacktoberfest'
  48. env:
  49. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  50. - name: Search for URL-based PR references
  51. run: |
  52. grep -Eo 'github.com/(.+)/(.+)/pull/([0-9]+)' log | sort | uniq | xargs -t -n1 -I{} \
  53. gh pr view 'https://{}' --json number,createdAt \
  54. --jq '{number, opened: .createdAt} | [.number, .opened] | join(":")' | tee /dev/stderr | \
  55. grep -Eo '^([0-9]+):[0-9]{4}-(09-30T|10-|11-01T)' | cut -d: -f1 | sort | uniq | xargs -t -n1 -I {} \
  56. gh pr edit {} --add-label 'hacktoberfest-accepted'
  57. if: steps.check.outputs.label == 'hacktoberfest'
  58. env:
  59. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}