From 1d2ce59187ddcbcae0139389679b5cd92f0fde4f Mon Sep 17 00:00:00 2001 From: Nicole Thoen Date: Wed, 18 Sep 2024 16:34:52 -0400 Subject: [PATCH] test update to GH action for issue creation --- .github/workflows/extensions.yml | 35 ++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/.github/workflows/extensions.yml b/.github/workflows/extensions.yml index 7fe2c56..15bfdc2 100644 --- a/.github/workflows/extensions.yml +++ b/.github/workflows/extensions.yml @@ -15,3 +15,38 @@ jobs: with: project-url: https://github.com/orgs/patternfly/projects/7 github-token: ${{ secrets.GH_PROJECTS }} + label-issue: + runs-on: ubuntu-latest + steps: + - name: Check if the author is on the team + id: check_team_membership + uses: actions/github-script@v6 + with: + script: | + const org = 'patternfly'; + const team_slug = 'frequent-flyers'; + const author = context.payload.issue.user.login; + + try { + const { data: membership } = await github.teams.getMembershipForUserInOrg({ + org: org, + team_slug: team_slug, + username: author + }); + + if (membership && membership.state === 'active') { + core.setOutput('is_team_member', 'true'); + } else { + core.setOutput('is_team_member', 'false'); + } + } catch (error) { + // If the user is not a team member, it will throw a 404 error + core.setOutput('is_team_member', 'false'); + } + + - name: Add label if user is a team member + if: steps.check_team_membership.outputs.is_team_member == 'true' + uses: actions-ecosystem/action-add-labels@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + labels: "frequent-flyer"