Skip to content
Open
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
16 changes: 13 additions & 3 deletions .github/workflows/pr-vibe-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ jobs:
check-pr:
name: Check Labels
runs-on: ubuntu-slim
permissions:
# Read access for `actions/checkout` and `gh pr view`.
contents: read
pull-requests: read
outputs:
all_labels: ${{ steps.all-labels.outputs.all_labels }}
new_labels: ${{ steps.new-labels.outputs.new_labels }}
Expand Down Expand Up @@ -56,12 +60,18 @@ jobs:
id: new-labels
env:
all_labels: ${{ steps.all-labels.outputs.all_labels }}
GH_TOKEN: ${{ github.token }}
run: |
EXISTING_LABELS='${{ toJson(github.event.pull_request.labels.*.name) }}';
# Query the labels currently on the PR rather than reading them from
# the event payload. The payload is a snapshot taken when the event
# was created, so labels the author adds right after opening the PR
# (a common case) would be missing from it and wrongly reported as
# newly added by the bot. See issue #584.
EXISTING_LABELS="$(gh pr view ${PR_NUM} --json labels --jq '.labels[].name')";
Comment on lines +65 to +70
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a 100% sure if this change is actually a good idea. If the tag is added at the moment the PR is created it should be in the payload already so we don't need to use the gh cli.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll still have the same problem anyway if human is faster than this line to be executed, no?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or we should just remove the commenting part. It's cute but makes things unnecessarily complicated I think....

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah maybe just remove the autocommenting.

new_labels=();
for label in ${all_labels[@]}; do
if [[ "$EXISTING_LABELS" == *"${label}"* ]]; then
echo "${label} is already added to the current PR.";
if grep -qxF "${label}" <<< "$EXISTING_LABELS"; then
echo "${label} is already added to the current PR.";
else
echo "Found a new label to be added: ${label}";
new_labels+=("${label}");
Expand Down