Skip to content

Commit

Permalink
add test for new labeler script
Browse files Browse the repository at this point in the history
  • Loading branch information
mastercactapus committed Sep 3, 2024
1 parent c78e4fe commit b590d8d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/labeler_v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: labeler v2

on:
pull_request:
types: ['opened', 'ready_for_review', 'reopened', 'synchronize']

jobs:
labeler:
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
name: Label the PR size
steps:
- uses: actions/checkout@v3
- name: Install jq
run: sudo apt-get install -y jq
- name: Run labeler script
run: ./devtools/scripts/github-set-pr-label.sh
22 changes: 22 additions & 0 deletions devtools/scripts/github-set-pr-label.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -e

if [ -z "$GITHUB_API_URL" ]; then
GITHUB_API_URL=https://api.github.com
fi

if [ -z "$GITHUB_TOKEN" ]; then
echo "GITHUB_TOKEN is not set"
exit 1
fi

PR_NUMBER=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
LABEL=$(./devtools/scripts/git-diff-label-calc.sh --debug)

curl -sSL \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
-X PATCH \
-H "Content-Type: application/json" \
-d "{\"labels\":[\"test/$LABEL\"]}" \
"$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER"

0 comments on commit b590d8d

Please sign in to comment.