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