X Tutup
Skip to content

Commit 75ac259

Browse files
committed
add workflow
1 parent eddd8f0 commit 75ac259

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

.github/workflows/prauto.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: PR Automation
2+
on:
3+
pull_request:
4+
types: [ready_for_review, opened, reopened]
5+
jobs:
6+
bash-redux:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: lint pr
10+
env:
11+
REPO: "cli/cli"
12+
NEEDSREVIEWCOL: "MDEzOlByb2plY3RDb2x1bW43MTEwMTI4"
13+
PRID: ${{ github.event.pull_request.node_id }}
14+
PRBODY: ${{ github.event.pull_request.body }}
15+
STAFF: "vilmibm,mislav,samcoe,billygriffin,ampinsk"
16+
PRNUM: ${{ github.event.pull_request.number }}
17+
PRBASE: ${{ github.event.pull_request.base.ref }}
18+
GH_TOKEN: ${{ secrets.AUTOMATION_TOKEN }}
19+
# Testing data:
20+
#REPO: "vilmibm/testing"
21+
#NEEDSREVIEWCOL: "MDEzOlByb2plY3RDb2x1bW4xMTAzNTA3Ng==" # vilmibm/testing "good" column
22+
run: |
23+
commentPR () {
24+
gh -R$REPO pr comment $PRNUM -b "${1}"
25+
}
26+
27+
closePR () {
28+
gh -R$REPO pr close $PRNUM
29+
}
30+
31+
addToBoard () {
32+
# this exec is an attempt to fix some quote highlighting issues i was having in my editor.
33+
bash -c 'gh api graphql -f query="mutation { addProjectCard(input: { projectColumnId: \"$NEEDSREVIEWCOL\", contentId: \"$PRID\" }) { clientMutationId } }"'
34+
}
35+
36+
if echo $STAFF | grep $PRAUTHOR
37+
then
38+
addToBoard
39+
exit 0
40+
fi
41+
42+
if echo $PRBODY | wc -w | grep '^[0-9]$'
43+
then
44+
commentPR "Thanks for the PR! We're a small team and it's helpful to have context around community submissions in order to review them appropriately. Our automation has closed this PR since the body appears to be lacking much content; please add a more descriptive PR body as well as any issues it closes and reopen. Thanks again!"
45+
closePR
46+
exit 0
47+
fi
48+
49+
if echo $PRBASE | grep -Ev "^trunk$"
50+
then
51+
commentPR "This pull request should probably be targeting trunk; since it isn't, our automation has closed it. Please reopen with an appropriate base branch if this was in error."
52+
closePR
53+
exit 0
54+
fi
55+
56+
if echo $PRBODY | grep -Ev " \#\d+ "
57+
then
58+
commentPR "Hi! Thanks for the PR. Please ensure that this PR is related to an issue by mentioning its issue number in the PR body. If this PR would close the issue, please put 'Fixes #<issue number>' somewhere in the PR body. If this is a tiny change like fixing a typo, feel free to ignore this message."
59+
# TODO should this be close-worthy? I feel like sometimes it's ok
60+
# to not have an issue (like a tiny typo fix) so we should have
61+
# this be a warning.
62+
fi
63+
64+
addToBoard
65+
exit 0

0 commit comments

Comments
 (0)
X Tutup