-
Notifications
You must be signed in to change notification settings - Fork 7
40 lines (38 loc) · 1.34 KB
/
wip.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
name: WIP Check
on:
pull_request:
# edited is to get notified about PR title changes
# ready_for_review to get notified when the PR changes from draft=true to
# draft=false
# The rest are the standard pull_request events to keep track to changes on
# commits and general PR status
types: [ edited, opened, ready_for_review, reopened, synchronize ]
jobs:
# In the future the PR could be converted to a Draft PR, but for now there
# is no API endpoint to update a PR to make it a draft.
wip-check:
runs-on: ubuntu-latest
if: '!github.event.pull_request.draft'
steps:
- name: Check if any commits start with WIP
run: |
title='${{github.event.pull_request.title}}'
r=0
if echo '$title' | grep -qiP '^WIP\b'
then
echo ::error "::The PR is a Work In Progress (WIP): $title"
r=$(($r+1))
fi
if wips=$(curl -s -H "Accept: application/vnd.github.v3+json" \
"${{github.event.pull_request.commits_url}}" \
| jq -r '.[].commit.message | capture("^(?<a>.*)").a' \
| grep -iP '^(WIP\b|(fixup|squash)!\s)') \
&& test -n "$wips"
then
while read wip
do
echo ::error "::Found WIP commit: $wip"
r=$(($r+1))
done <<< "$wips"
fi
exit $r