Skip to content

Commit

Permalink
Reworked service labeler to act in more cases (#17794)
Browse files Browse the repository at this point in the history
* Reworked service labeler to act in more cases

Specifically, if labels are removed or if the first comment is edited - but only if there is not a service label yet.

* Added temporary pull_request triggers

* Removed toJson

* Display picked labels

* Temporarily switch to pull_request data for testing

* Use compact jq output

* Removed references to pull_request events
  • Loading branch information
melinath committed Apr 8, 2024
1 parent ef13bca commit 4f7c4fe
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Issue Opened Self-Service Labeler
name: Service Labeler

on:
issues:
types: [opened]
types: [opened, edited, unlabeled]

jobs:
add-labels:
Expand All @@ -20,16 +20,25 @@ jobs:
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: '>=1.19.0'
- name: Check for service labels
id: service_labels
run: |
serviceLabels="$(echo '${{ toJson(github.event.issue.labels.*.name) }}' | jq -c 'map(select(startswith("service/")))')"
echo "Service labels: $serviceLabels"
echo "service_labels=$serviceLabels" >> $GITHUB_OUTPUT
- name: Pick labels
id: pick_labels
if: ${{ steps.service_labels.outputs.service_labels == '[]' }}
env:
ISSUE_BODY: ${{ github.event.issue.body }}
run: |
cd magic-modules/tools/issue-labeler
echo "labels=$(go run .)" >> $GITHUB_OUTPUT
labels=$(go run .)
echo "Labels: $labels"
echo "labels=$labels" >> $GITHUB_OUTPUT
- name: Apply labels
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
if: ${{ steps.pick_labels.outputs.labels != '' }}
if: ${{ steps.service_labels.outputs.service_labels == '[]' && steps.pick_labels.outputs.labels != '' }}
with:
script: |
github.rest.issues.addLabels({
Expand Down

0 comments on commit 4f7c4fe

Please sign in to comment.