Skip to content

Commit 4280b49

Browse files
committed
ci: add pr automatization
1 parent 451167e commit 4280b49

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

.github/workflows/pr.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
on:
2+
pull_request:
3+
types: [opened]
4+
5+
jobs:
6+
check-description:
7+
name: Check that PR has description
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Check if PR is shame-worthy
12+
id: is-shame-worthy
13+
run: |
14+
FILTERED_BODY=$( sed -r -e '/^(##? )|(- *\[)/d' <<< $RAW_BODY )
15+
echo "::debug::Filtered PR body to $FILTERED_BODY"
16+
if [[ -z "${FILTERED_BODY//[[:space:]]/}" ]]; then
17+
echo "::set-output name=is-shame-worthy::true"
18+
else
19+
echo "::set-output name=is-shame-worthy::false"
20+
fi
21+
env:
22+
RAW_BODY: ${{ github.event.pull_request.body }}
23+
24+
- name: Shame if PR has no description
25+
if: steps.is-shame-worthy.outputs.is-shame-worthy == 'true'
26+
run: |
27+
SHAME_BODY="Hey @${{ github.actor }}! 👋\nThis pull request seems to contain no description. Please add useful context, rationale, and/or any other information that will help make sense of this change now and in the distant Mars-based future."
28+
curl -s -u posthog-bot:${{ secrets.GITHUB_TOKEN }} -X POST -d "{ \"body\": \"$SHAME_BODY\" }" "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments"

.github/workflows/stale-pr.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: 'Handle stale PRs'
2+
on:
3+
schedule:
4+
- cron: '30 7 * * 1-5'
5+
6+
jobs:
7+
stale:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/stale@v4
11+
with:
12+
only: pulls
13+
stale-pr-message: "This PR hasn't seen activity in a week! Should it be merged, closed, or worked on further? If you want to keep it open, post a comment or remove the `stale` label – otherwise this will be closed in another week."
14+
close-pr-message: 'This PR was closed due to 2 weeks of inactivity. Feel free to reopen it if still relevant.'
15+
days-before-pr-stale: 7
16+
days-before-pr-close: 7
17+
stale-issue-label: stale
18+
stale-pr-label: stale

0 commit comments

Comments
 (0)