From 5c9496de70fd1fe3dacca4bfe020c2aef7c8ca7a Mon Sep 17 00:00:00 2001 From: Den Delimarsky <53200638+localden@users.noreply.github.com> Date: Thu, 1 Aug 2024 08:33:57 -0700 Subject: [PATCH] Add automated logic for tagging issues (#4866) * Create label-issues.yml * Update label-issues.yml --- .github/workflows/label-issues.yml | 59 ++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/label-issues.yml diff --git a/.github/workflows/label-issues.yml b/.github/workflows/label-issues.yml new file mode 100644 index 0000000000..edcffa09a1 --- /dev/null +++ b/.github/workflows/label-issues.yml @@ -0,0 +1,59 @@ +name: Label Client Issues + +on: + issues: + types: [opened, edited] + +permissions: + issues: write + +jobs: + label: + runs-on: ubuntu-latest + + steps: + - name: Check issue body for client type + id: check_label + uses: actions/github-script@v7 + with: + script: | + const labelsToAdd = []; + const publicClientOptions = [ + "PublicClient" + ]; + const confidentialClientOptions = [ + "ConfidentialClient" + ]; + const managedIdentityClientOptions = [ + "ManagedIdentityClient" + ]; + + const issueBody = context.issue.body; + + if (publicClientOptions.some(option => issueBody.includes(option))) { + labelsToAdd.push('public-client'); + } + + if (confidentialClientOptions.some(option => issueBody.includes(option))) { + labelsToAdd.push('confidential-client'); + } + + if (managedIdentityClientOptions.some(option => issueBody.includes(option))) { + labelsToAdd.push('scenario:ManagedIdentity'); + } + + return labelsToAdd; + + - name: Add labels to the issue + uses: actions/github-script@v7 + with: + script: | + const labels = ${{ steps.check_label.outputs.result }}; + if (labels.length > 0) { + await github.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + labels: labels + }); + } \ No newline at end of file