Skip to content

Commit

Permalink
ci: script to add label to PR based on edited package
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Molisani <[email protected]>
  • Loading branch information
molisani committed Oct 21, 2024
1 parent 2bb4b8d commit 2104415
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/pr_labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Add package labels to PR

on:
pull_request:
types:
- opened
- reopened
- synchronize

permissions:
actions: read
contents: read
pull-requests: write

jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- run: ./scripts/add_labels_to_pr.sh
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.pull_request.number }}
21 changes: 21 additions & 0 deletions scripts/add_labels_to_pr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

for diff_file in $(git diff main...HEAD --name-only); do
if [[ $diff_file == packages/core/* ]] && [[ -z "$ADDED_CORE_LABEL" ]]; then
echo "Change found in packages/core, adding label for core"
gh pr edit $PR_NUMBER --add-label "core ⚙"
ADDED_CORE_LABEL = 1
fi

if [[ $diff_file == packages/auto-complete/* ]] && [[ -z "$ADDED_AUTO_COMPLETE_LABEL" ]]; then
echo "Change found in packages/auto-complete, adding label for auto-complete"
gh pr edit $PR_NUMBER --add-label "auto-complete 🔮"
ADDED_AUTO_COMPLETE_LABEL = 1
fi

if [[ $diff_file == packages/create-app/* ]] && [[ -z "$ADDED_CREATE_APP_LABEL" ]]; then
echo "Change found in packages/create-app, adding label for create-app"
gh pr edit $PR_NUMBER --add-label "create-app 📂"
ADDED_CREATE_APP_LABEL = 1
fi
done

0 comments on commit 2104415

Please sign in to comment.