-
Notifications
You must be signed in to change notification settings - Fork 2
/
action.yml
42 lines (41 loc) · 1.23 KB
/
action.yml
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
name: 'PR Size Checker'
description: 'Check PR total lines changed'
inputs:
max_lines_changed: # id of input
description: 'Maximum number of lines changed allowed'
required: true
default: '200'
target_branch:
description: The branch to compare against
required: true
default: main
outputs:
total_lines_changed:
description: 'Total lines changed in this PR'
value: ${{ steps.get_total_lines_changed.outputs.random-id }}
runs:
using: "composite"
steps:
- id: get_total_lines_changed
run: |
size=$(git diff --stat origin/${{ inputs.target_branch }} \
| grep -v .lock \
| grep -v Bin \
| awk -F"|" '{ print $2 }' \
| awk '{ print $1 }' \
| sed '/^$/d' \
| paste -sd+ - \
| bc)
echo "size=${size}" >> $GITHUB_ENV
echo ""
echo "Total lines changed (note: *.lock files are excluded from this count): "
echo $size
shell: bash
- run: |
if [[ $size -gt ${{ inputs.max_lines_changed }} ]]
then
echo "Warning - total lines changed is greater than" ${{ inputs.max_lines_changed }}.
echo "Please consider breaking this PR down."
exit 1
fi
shell: bash