From 2b04186b0fe9ff204cfd7873b6796d9d55797cdd Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Thu, 11 Sep 2025 11:07:11 -0400 Subject: [PATCH] Only run congratsbot for non-staff (#38000) Release Notes: - N/A --- .github/workflows/congrats.yml | 45 +++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/.github/workflows/congrats.yml b/.github/workflows/congrats.yml index c5dfc122647d9c422b850e743e6d679643fe4c58..e8af621c440cf8268f402eb619cb3dc75b18d591 100644 --- a/.github/workflows/congrats.yml +++ b/.github/workflows/congrats.yml @@ -5,8 +5,51 @@ on: branches: [main] jobs: - congrats: + check-author: if: ${{ github.repository_owner == 'zed-industries' }} + runs-on: ubuntu-latest + outputs: + should_congratulate: ${{ steps.check.outputs.should_congratulate }} + steps: + - name: Get PR info and check if author is external + id: check + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const { data: prs } = await github.rest.repos.listPullRequestsAssociatedWithCommit({ + owner: context.repo.owner, + repo: context.repo.repo, + commit_sha: context.sha + }); + + if (prs.length === 0) { + core.setOutput('should_congratulate', 'false'); + return; + } + + const mergedPR = prs.find(pr => pr.merged_at !== null) || prs[0]; + const prAuthor = mergedPR.user.login; + + try { + await github.rest.teams.getMembershipForUserInOrg({ + org: 'zed-industries', + team_slug: 'staff', + username: prAuthor + }); + core.setOutput('should_congratulate', 'false'); + } catch (error) { + if (error.status === 404) { + core.setOutput('should_congratulate', 'true'); + } else { + console.error(`Error checking team membership: ${error.message}`); + core.setOutput('should_congratulate', 'false'); + } + } + + congrats: + needs: check-author + if: needs.check-author.outputs.should_congratulate == 'true' uses: withastro/automation/.github/workflows/congratsbot.yml@main secrets: DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_CONGRATS }}