인게임 구현 #40
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PR Size Labeler | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
jobs: | |
label-pr-size: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Get PR size | |
id: pr_size | |
run: | | |
CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | wc -l) | |
CHANGED_LINES=$(git diff --numstat ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | awk '{add += $1 + $2} END {print add}') | |
echo "changed_files=$CHANGED_FILES" >> $GITHUB_ENV | |
echo "changed_lines=$CHANGED_LINES" >> $GITHUB_ENV | |
- name: Set size label | |
run: | | |
if [ ${{ env.changed_lines }} -lt 10 ]; then | |
SIZE_LABEL="size/XS" | |
elif [ ${{ env.changed_lines }} -lt 50 ]; then | |
SIZE_LABEL="size/S" | |
elif [ ${{ env.changed_lines }} -lt 200 ]; then | |
SIZE_LABEL="size/M" | |
elif [ ${{ env.changed_lines }} -lt 500 ]; then | |
SIZE_LABEL="size/L" | |
else | |
SIZE_LABEL="size/XL" | |
fi | |
echo "PR size is $SIZE_LABEL" | |
# Remove old size labels | |
gh pr edit ${{ github.event.pull_request.number }} --remove-label "size/XS" || true | |
gh pr edit ${{ github.event.pull_request.number }} --remove-label "size/S" || true | |
gh pr edit ${{ github.event.pull_request.number }} --remove-label "size/M" || true | |
gh pr edit ${{ github.event.pull_request.number }} --remove-label "size/L" || true | |
gh pr edit ${{ github.event.pull_request.number }} --remove-label "size/XL" || true | |
# Add new size label | |
gh pr edit ${{ github.event.pull_request.number }} --add-label "$SIZE_LABEL" | |
env: | |
GITHUB_TOKEN: ${{ secrets.G_TOKEN }} |