From efa6a6c62493965b556025535ad4b7347229abef Mon Sep 17 00:00:00 2001 From: Armand Grillet <2117580+armandgrillet@users.noreply.github.com> Date: Fri, 29 Sep 2023 17:36:52 +0200 Subject: [PATCH] Fix issue-labeled GitHub Action (#75753) --- .github/workflows/issue-labeled.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/issue-labeled.yml b/.github/workflows/issue-labeled.yml index 66d4ff6aac4..de4d9b0000f 100644 --- a/.github/workflows/issue-labeled.yml +++ b/.github/workflows/issue-labeled.yml @@ -64,15 +64,21 @@ jobs: - name: "Check that issue author is not part of the team" if: ${{ env.TEAM != 'null' }} - uses: tspascoal/get-user-teams-membership@v2 - id: checkUserMember - with: - username: ${{ github.event.issue.user.login }} - team: "${{ env.TEAM }}" + run: | + response=$(gh api /orgs/grafana/teams/${{ env.TEAM }}/memberships/${{ github.event.issue.user.login }} -i -H "Accept: application/vnd.github.v3+json") + STATUS_CODE=$(echo "$response" | head -n 1 | cut -d' ' -f2) + if [ "$status_code" -eq 404 ]; then + echo "The user was not found in the team." + echo "USER_FOUND=false" >> $GITHUB_ENV + else + echo "The user was potentially found in the team" + echo "USER_FOUND=maybe" >> $GITHUB_ENV + fi + env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: "Send Slack notification" - if: ${{ (env.CHANNEL != 'null') && ((steps.checkUserMember.outputs.isTeamMember == 'false') || (env.TEAM != 'null')) }} + if: ${{ (env.CHANNEL != 'null') && ((env.USER_FOUND == 'false') || (env.TEAM != 'null')) }} uses: slackapi/slack-github-action@v1.24.0 with: payload: >