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