Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.

Commit 3e9a2f5

Browse files
authored
Update size-label.yml to get the labels based on PR size
1 parent 05098e9 commit 3e9a2f5

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

.github/workflows/size-label.yml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,19 @@ jobs:
77
pull-requests: write
88
runs-on: ubuntu-latest
99
steps:
10+
- name: Install jq
11+
run: |
12+
sudo apt-get update
13+
sudo apt-get install -y jq
1014
- name: Size label
1115
uses: actions/checkout@v3
1216
with:
1317
token: ${{ secrets.GITHUB_TOKEN }}
14-
- name: Install hub
15-
run: |
16-
sudo apt-get update
17-
sudo apt-get install -y hub
1818
- name: Calculate size
1919
run: |
20-
if git rev-parse HEAD~1 >/dev/null 2>&1; then
21-
git fetch origin main --update-shallow
22-
git diff --stat HEAD~1
23-
size=$(cat .git/FETCH_HEAD | wc -l)
24-
else
25-
echo "No previous commits"
26-
size=0
27-
fi
20+
additions=$(curl -s "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}" | jq '.additions')
21+
deletions=$(curl -s "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}" | jq '.deletions')
22+
size=$((additions + deletions))
2823
echo "SIZE=$size" >> $GITHUB_ENV
2924
- name: Add label
3025
run: |
@@ -65,3 +60,4 @@ jobs:
6560
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels \
6661
-d '["size: XS"]'
6762
fi
63+

0 commit comments

Comments
 (0)