generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 81
46 lines (43 loc) · 1.58 KB
/
large-pr-checker.yml
File metadata and controls
46 lines (43 loc) · 1.58 KB
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
41
42
43
44
45
46
# ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen".
name: large-pr-checker
on:
pull_request:
branches:
- main
types:
- labeled
- edited
- opened
- reopened
- unlabeled
jobs:
check:
name: Check PR size
runs-on: ubuntu-latest
permissions:
pull-requests: write
if: ${{ !contains(github.event.pull_request.labels.*.name, 'pr/exempt-size-check') }}
steps:
- name: Checkout
uses: actions/checkout@v5
- id: fetch_target_branch
run: git fetch origin main
- id: get_total_lines_changed
run: |-
size=$(git diff --shortstat origin/main ':(exclude)*.md' ':(exclude)*.test.ts' ':(exclude)*.yml' ':(exclude)*.lock' \
| awk '{ print $4+$6 }' \
| awk -F- '{print $NF}' \
| bc)
size=${size:-0}
echo "Total lines changed: $size"
echo "total_lines_changed=$size" >> $GITHUB_OUTPUT
- id: comment_pr
if: ${{ fromJSON(steps.get_total_lines_changed.outputs.total_lines_changed) > fromJSON(1000) }}
uses: thollander/actions-comment-pull-request@v2
with:
comment_tag: pr_size
mode: recreate
message: Total lines changed ${{ steps.get_total_lines_changed.outputs.total_lines_changed }} is greater than 1000. Please consider breaking this PR down.
- id: fail
if: ${{ fromJSON(steps.get_total_lines_changed.outputs.total_lines_changed) > fromJSON(1000) }}
run: exit 1