Skip to content

Commit 35d45be

Browse files
authored
ci(e2e): add org membership check to e2e-staging workflow (#8144)
1 parent 6540d1b commit 35d45be

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

.github/workflows/e2e-staging.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,39 @@ concurrency:
3737
cancel-in-progress: true
3838

3939
jobs:
40+
permissions-check:
41+
name: Check Permissions
42+
runs-on: 'blacksmith-8vcpu-ubuntu-2204'
43+
steps:
44+
- name: Check org membership
45+
uses: actions/github-script@v7
46+
with:
47+
script: |
48+
const org = context.repo.owner;
49+
const username = process.env.GITHUB_TRIGGERING_ACTOR || context.actor;
50+
51+
try {
52+
const { status } = await github.rest.orgs.checkMembershipForUser({
53+
org,
54+
username,
55+
});
56+
57+
if (status !== 204) {
58+
core.setFailed(`User '${username}' is not a member of the '${org}' organization.`);
59+
}
60+
} catch (error) {
61+
if (error?.status === 404) {
62+
core.setFailed(`User '${username}' is not a member of the '${org}' organization.`);
63+
} else {
64+
core.setFailed(
65+
`Org membership check failed for '${username}' in '${org}' (status: ${error?.status ?? 'unknown'}): ${error?.message ?? 'unknown error'}`
66+
);
67+
}
68+
}
69+
4070
validate-instances:
4171
name: Validate Staging Instances
72+
needs: [permissions-check]
4273
runs-on: 'blacksmith-8vcpu-ubuntu-2204'
4374
steps:
4475
- name: Checkout Repo
@@ -56,6 +87,7 @@ jobs:
5687

5788
integration-tests:
5889
name: Integration Tests (${{ matrix.test-name }}, ${{ matrix.test-project }})
90+
needs: [permissions-check]
5991
runs-on: 'blacksmith-8vcpu-ubuntu-2204'
6092
defaults:
6193
run:

0 commit comments

Comments
 (0)