Skip to content

Commit

Permalink
Merge pull request #366 from MartinBasti/mark-PR-size
Browse files Browse the repository at this point in the history
chore(workflow): mark size of PRs
  • Loading branch information
MartinBasti authored Oct 19, 2023
2 parents 9808d7b + 65650c1 commit c415fd0
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/size.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Pull request size
on: pull_request_target

jobs:
size-label:
name: Size label
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Calculate size
run: |
#!/usr/bin/bash
set -euo pipefail
additions=$(curl -s "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}" | jq '.additions')
deletions=$(curl -s "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}" | jq '.deletions')
size=$((additions + deletions))
sizelabel=XS
if [ ${size} -gt 500 ]; then
sizelabel="XXL"
elif [ ${size} -gt 200 ]; then
sizelabel="XL"
elif [ ${size} -gt 100 ]; then
sizelabel="L"
elif [ ${size} -gt 50 ]; then
sizelabel="M"
elif [ ${size} -gt 30 ]; then
sizelabel="S"
fi
echo "Adding size: ${sizelabel}"
curl -s --fail-with-body -X POST -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels \
-d "[\"size: ${sizelabel}\"]"

0 comments on commit c415fd0

Please sign in to comment.