Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update autolabeler workflow again #1868

Merged
merged 2 commits into from
Jan 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions .github/workflows/label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ jobs:
label-pull-request:
runs-on: ubuntu-latest

# This workflow is not useful to forks without significantly updating the workflow script.
if: ${{ github.repository == 'TurboWarp/extensions' }}

permissions:
pull-requests: write

Expand All @@ -32,20 +35,20 @@ jobs:

if [[ "$BASE_REF" == "master" ]]; then
# Download just the diff so it is harder to accidentally run any code from the pull request.
gh pr diff --repo TurboWarp/desktop "$PR_NUMBER" > pr.diff
gh pr diff --repo TurboWarp/extensions "$PR_NUMBER" > pr.diff

# Note that pcregrep exits with success on any match, failure on no match
if pcregrep -M "^--- /dev/null\n\+\+\+ b/extensions/" pr.diff; then
# Example:
# --- /dev/null
# +++ b/extensions/DangoCat/extension.js
gh pr edit --repo TurboWarp/desktop "$PR_NUMBER" --add-label "$LABEL_NEW_EXTENSION"
gh pr edit --repo TurboWarp/extensions "$PR_NUMBER" --add-label "$LABEL_NEW_EXTENSION"
got_any_specific_label=true
elif pcregrep "^\+\+\+ b/extensions/" pr.diff; then
# Example:
# --- a/extensions/DangoCat/extension.js
# +++ b/extensions/DangoCat/extension.js
gh pr edit --repo TurboWarp/desktop "$PR_NUMBER" --add-label "$LABEL_CHANGE_EXTENSION"
gh pr edit --repo TurboWarp/extensions "$PR_NUMBER" --add-label "$LABEL_CHANGE_EXTENSION"
got_any_specific_label=true
fi
else
Expand All @@ -54,7 +57,7 @@ jobs:

# Any PR that didn't get a specific label will go into other, for a human to look at.
if [[ "$got_any_specific_label" == "false" ]]; then
gh pr edit --repo TurboWarp/desktop "$PR_NUMBER" --add-label "$LABEL_OTHER"
gh pr edit --repo TurboWarp/extensions "$PR_NUMBER" --add-label "$LABEL_OTHER"
fi
env:
PR_NUMBER: "${{ github.event.number }}"
Expand Down
Loading