Skip to content

chore(deps): Bump golang from 87a41d2 to 792443b #300

chore(deps): Bump golang from 87a41d2 to 792443b

chore(deps): Bump golang from 87a41d2 to 792443b #300

Workflow file for this run

name: PR Size
on:
pull_request_target:
types: [opened, synchronize]
permissions:
contents: read
concurrency:
group: pr-size-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
size-label:
name: Label PR size
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
pull-requests: write
issues: write
steps:
- uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: audit
# No checkout needed: this workflow only reads event payload data and
# calls the GitHub API. Removing the checkout eliminates the
# "untrusted code in privileged context" code-scanning alert.
- name: Calculate diff size and apply label
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.pull_request.number }}
ADDITIONS: ${{ github.event.pull_request.additions }}
DELETIONS: ${{ github.event.pull_request.deletions }}
REPO: ${{ github.repository }}
run: |
TOTAL=$((ADDITIONS + DELETIONS))
if [ "$TOTAL" -lt 10 ]; then
SIZE="size/xs"
elif [ "$TOTAL" -lt 50 ]; then
SIZE="size/s"
elif [ "$TOTAL" -lt 250 ]; then
SIZE="size/m"
elif [ "$TOTAL" -lt 500 ]; then
SIZE="size/l"
else
SIZE="size/xl"
fi
echo "PR #${PR_NUMBER}: +${ADDITIONS} -${DELETIONS} = ${TOTAL} lines -> ${SIZE}"
# Fetch current labels, swap the size/* label in one API call
KEEP=$(gh api "repos/${REPO}/issues/${PR_NUMBER}" --jq \
'[.labels[].name | select(startswith("size/") | not)]')
FINAL=$(echo "$KEEP" | jq --arg s "$SIZE" '. + [$s]')
echo "$FINAL" | jq '{labels: .}' | \
gh api "repos/${REPO}/issues/${PR_NUMBER}/labels" --method PUT --input -
# Post a warning comment for XL PRs
if [ "$SIZE" = "size/xl" ]; then
gh pr comment "$PR_NUMBER" --repo "${REPO}" \
--body "> **Large PR** (+${ADDITIONS} -${DELETIONS} = ${TOTAL} lines). Consider splitting into smaller, focused PRs for easier review." \
2>/dev/null || true
fi