summaryrefslogtreecommitdiff
path: root/.github
diff options
context:
space:
mode:
authorMarc Hoersken <info@marc-hoersken.de>2021-10-23 21:30:03 +0200
committerMarc Hoersken <info@marc-hoersken.de>2021-10-27 12:26:31 +0200
commitf0ab8a631aeaa4cb458d55f25313080416adf43e (patch)
treefa09c0618b705f0c3151461891b45bdc2b1bf96d /.github
parentc67a32fc560913caff7875bb4fe98abb9991798c (diff)
downloadcurl-f0ab8a631aeaa4cb458d55f25313080416adf43e.tar.gz
github: add support for Hacktoberfest using labels
Automatically add hacktoberfest-accepted label to PRs opened between September 30th and November 1st once a commit with a close reference to it is pushed onto the master branch. With this workflow we can participate in Hacktoberfest while not relying on GitHub to identify PRs as merged due to our rebasing. Requires hacktoberfest-accepted labels to exist for PRs on the participating repository. Also requires hacktoberfest topic on the participating repository to avoid applying to forked repos. Reviewed-by: Daniel Stenberg Fixes #7865 Closes #7897
Diffstat (limited to '.github')
-rw-r--r--.github/workflows/hacktoberfest-accepted.yml53
1 files changed, 53 insertions, 0 deletions
diff --git a/.github/workflows/hacktoberfest-accepted.yml b/.github/workflows/hacktoberfest-accepted.yml
new file mode 100644
index 000000000..0ab7969c1
--- /dev/null
+++ b/.github/workflows/hacktoberfest-accepted.yml
@@ -0,0 +1,53 @@
+name: Hacktoberfest
+
+on:
+ # run for all pushes to master branch
+ push:
+ branches:
+ - master
+
+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:
+ - uses: actions/checkout@v2
+ with:
+ fetch-depth: 100
+
+ - name: Check wether repo participates in Hacktoberfest
+ 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 }}