From 4f7c4fef843cdf11269c78dc1405b7361e6a17c9 Mon Sep 17 00:00:00 2001 From: "Stephen Lewis (Burrows)" Date: Mon, 8 Apr 2024 14:08:18 -0700 Subject: [PATCH] Reworked service labeler to act in more cases (#17794) * 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 --- ...-service-labeler.yml => service-labeler.yml} | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) rename .github/workflows/{self-service-labeler.yml => service-labeler.yml} (60%) diff --git a/.github/workflows/self-service-labeler.yml b/.github/workflows/service-labeler.yml similarity index 60% rename from .github/workflows/self-service-labeler.yml rename to .github/workflows/service-labeler.yml index 4e638b129a1..d0897990c2b 100644 --- a/.github/workflows/self-service-labeler.yml +++ b/.github/workflows/service-labeler.yml @@ -1,8 +1,8 @@ -name: Issue Opened Self-Service Labeler +name: Service Labeler on: issues: - types: [opened] + types: [opened, edited, unlabeled] jobs: add-labels: @@ -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({