diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index e5f4aa9e2..8f74dcfde 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -23,23 +23,35 @@ jobs: outputs: is_authorized: ${{ steps.check.outputs.is_authorized }} steps: - - name: Check authorization + - name: Check team membership id: check - run: | - if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then - echo "✅ Manual workflow dispatch — authorized" - echo "is_authorized=true" >> "$GITHUB_OUTPUT" - exit 0 - fi - AUTHORIZED_USERS="${{ secrets.AUTHORIZED_USERS }}" - if [[ ",$AUTHORIZED_USERS," == *",${{ github.actor }},"* ]]; then - echo "✅ User ${{ github.actor }} is authorized" - echo "is_authorized=true" >> "$GITHUB_OUTPUT" - else - echo "⏭️ User ${{ github.actor }} is not in AUTHORIZED_USERS — skipping E2E tests." - echo "ℹ️ External contributors: ask a maintainer to run the E2E tests manually via workflow_dispatch." - echo "is_authorized=false" >> "$GITHUB_OUTPUT" - fi + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.TEAM_CHECK_TOKEN }} + script: | + if (context.eventName === 'workflow_dispatch') { + core.info('✅ Manual workflow dispatch — authorized'); + core.setOutput('is_authorized', 'true'); + return; + } + try { + const { data } = await github.rest.teams.getMembershipForUserInOrg({ + org: 'aws', + team_slug: 'agentcore-devex-devs', + username: context.actor, + }); + if (data.state === 'active') { + core.info(`✅ User ${context.actor} is a member of aws/agentcore-devex-devs`); + core.setOutput('is_authorized', 'true'); + } else { + core.info(`⏭️ User ${context.actor} has pending membership — skipping E2E tests.`); + core.setOutput('is_authorized', 'false'); + } + } catch (error) { + core.info(`⏭️ User ${context.actor} is not a member of aws/agentcore-devex-devs — skipping E2E tests.`); + core.info('ℹ️ External contributors: ask a maintainer to run the E2E tests manually via workflow_dispatch.'); + core.setOutput('is_authorized', 'false'); + } e2e: needs: authorize