-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: script to add label to PR based on diff
Signed-off-by: Michael Molisani <[email protected]>
- Loading branch information
Showing
2 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Add 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 }} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env bash | ||
|
||
diff_result=$(git diff --name-only origin/main..HEAD) | ||
|
||
if [[ "${diff_result[*]}" =~ packages/core/* ]]; then | ||
echo "Change found in packages/core, adding label for core" | ||
gh pr edit $PR_NUMBER --add-label "core ⚙" | ||
else | ||
echo "No changes found in packages/core, removing label for core" | ||
gh pr edit $PR_NUMBER --remove-label "core ⚙" | ||
fi | ||
|
||
if [[ "${diff_result[*]}" =~ packages/auto-complete/* ]]; then | ||
echo "Change found in packages/auto-complete, adding label for auto-complete" | ||
gh pr edit $PR_NUMBER --add-label "auto-complete 🔮" | ||
else | ||
echo "No changes found in packages/auto-complete, removing label for auto-complete" | ||
gh pr edit $PR_NUMBER --remove-label "auto-complete 🔮" | ||
fi | ||
|
||
if [[ "${diff_result[*]}" =~ packages/create-app/* ]]; then | ||
echo "Change found in packages/create-app, adding label for create-app" | ||
gh pr edit $PR_NUMBER --add-label "create-app 📂" | ||
else | ||
echo "No changes found in packages/create-app, removing label for create-app" | ||
gh pr edit $PR_NUMBER --remove-label "create-app 📂" | ||
fi | ||
|
||
if [[ "${diff_result[*]}" =~ docs/* ]]; then | ||
echo "Change found in docs, adding label for documentation" | ||
gh pr edit $PR_NUMBER --add-label "documentation 📝" | ||
else | ||
echo "No changes found in docs, removing label for documentation" | ||
gh pr edit $PR_NUMBER --remove-label "documentation 📝" | ||
fi | ||
|
||
if [[ "${diff_result[*]}" =~ .github/workflows/* ]]; then | ||
echo "Change found in .github/workflows, adding label for ci" | ||
gh pr edit $PR_NUMBER --add-label "ci 🤖" | ||
else | ||
echo "No changes found in .github/workflows, removing label for ci" | ||
gh pr edit $PR_NUMBER --remove-label "ci 🤖" | ||
fi |