From 1c719a998cf251c27a92975832ec4c1f37d63597 Mon Sep 17 00:00:00 2001 From: sricker-nvidia <115114531+sricker-nvidia@users.noreply.github.com> Date: Thu, 10 Apr 2025 17:21:15 -0700 Subject: Add a workflow for auto labeling issues (#6776) Change introduces a workflow that will automatically run on new issues and add a "Dev Opened" label if opened by select dev members. This workflow can be used to add additional labels in the future. --- .github/workflows/add-issue-labels.yml | 61 ++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/workflows/add-issue-labels.yml (limited to '.github/workflows') diff --git a/.github/workflows/add-issue-labels.yml b/.github/workflows/add-issue-labels.yml new file mode 100644 index 000000000..cd0189443 --- /dev/null +++ b/.github/workflows/add-issue-labels.yml @@ -0,0 +1,61 @@ +name: Add Issue Labels + +on: + issues: + types: [opened] + workflow_dispatch: + inputs: + test_username: + description: "GitHub username to test with" + required: true + type: string + +jobs: + add-dev-opened-label: + runs-on: ubuntu-latest + permissions: + issues: write + contents: read + steps: + - name: Check if issue creator is in Nvidia dev team + id: check_team + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.SLANGBOT_PAT }} + script: | + const response = await github.rest.teams.listMembersInOrg({ + org: 'shader-slang', + team_slug: 'dev' + }); + + // For testing, use the provided username otherwise use the actual issue creator + const username = '${{ github.event.inputs.test_username || github.event.issue.user.login }}'; + + // Check if user is in the Nvidia dev team + const isTeamMember = response.data.some(member => + member.login === username && + member.login !== 'fairywreath' + ); + + console.log(`Checking membership for: ${username}`); + console.log(`Is Nvidia dev team member: ${isTeamMember}`); + + core.setOutput('is_team_member', isTeamMember); + + - name: Add Dev Opened Label + if: steps.check_team.outputs.is_team_member == 'true' + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.SLANGBOT_PAT }} + script: | + // Only add label if this is a real issue and not a test run + if (context.eventName === 'issues') { + github.rest.issues.addLabels({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + labels: ['Dev Opened'] + }); + } else { + console.log('Test run - would add label to issue if this was a real issue'); + } -- cgit v1.2.3