File tree 2 files changed +70
-0
lines changed
{{cookiecutter.project_name}}/.github
2 files changed +70
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : " Large PR checker"
2
+ description : " Blocks PR if number of lines changed is excessive. Modified version of https://github.com/adolfosilva/gh-large-pr-check/blob/main/action.yml"
3
+
4
+ inputs :
5
+ max_lines_changed :
6
+ description : " Maximum number of lines changed allowed"
7
+ required : true
8
+ default : " 500"
9
+ target_branch :
10
+ description : The branch to compare against
11
+ required : true
12
+ default : main
13
+ outputs :
14
+ total_lines_changed :
15
+ description : " Total lines changed in this PR"
16
+ value : ${{ steps.get_total_lines_changed.outputs.total_lines_changed }}
17
+
18
+ runs :
19
+ using : " composite"
20
+ steps :
21
+ - id : fetch_target_branch
22
+ run : |
23
+ git fetch origin ${{ inputs.target_branch }}
24
+ shell : bash
25
+ - id : get_total_lines_changed
26
+ run : |
27
+ size=$(git diff --shortstat origin/${{ inputs.target_branch }} ':(exclude)*.lock' \
28
+ | awk '{ print $4+$6 }' \
29
+ | awk -F- '{print $NF}' \
30
+ | bc)
31
+
32
+ echo ""
33
+ echo "Total lines changed (note: *.lock files are excluded from this count): $size"
34
+ echo "total_lines_changed=$size" >> $GITHUB_OUTPUT
35
+ shell : bash
36
+ - name : Comment PR
37
+ if : ${{ fromJSON(steps.get_total_lines_changed.outputs.total_lines_changed) > fromJSON(inputs.max_lines_changed) }}
38
+ uses : thollander/actions-comment-pull-request@v2
39
+ with :
40
+ comment_tag : pr_size
41
+ mode : recreate
42
+ message : |
43
+ :boom: :boom: :boom:
44
+ Total lines changed ${{ steps.get_total_lines_changed.outputs.total_lines_changed }} is greater than ${{ inputs.max_lines_changed }}.
45
+ Please consider breaking this PR down.
46
+ - id : fail
47
+ if : ${{ fromJSON(steps.get_total_lines_changed.outputs.total_lines_changed) > fromJSON(inputs.max_lines_changed) }}
48
+ run : exit 1
49
+ shell : bash
Original file line number Diff line number Diff line change
1
+ name : Validate & Lint & Test
2
+
3
+ on : [pull_request]
4
+
5
+ concurrency :
6
+ group : ${{ github.workflow }}-${{ github.ref }}
7
+ cancel-in-progress : true
8
+
9
+ jobs :
10
+ check-pr-diff :
11
+ runs-on : ubuntu-latest
12
+
13
+ steps :
14
+ - name : Checkout repository
15
+ uses : actions/checkout@v4
16
+
17
+ - name : Check PR diff size
18
+ uses : ./.github/actions/large-pr-check
19
+ with :
20
+ target_branch : ${{ github.event.pull_request.base.ref }}
21
+ max_lines_changed : 100
You can’t perform that action at this time.
0 commit comments