Skip to content

Commit 251bc42

Browse files
[CFX-6498] fix(ci): validate fork smoke dispatch initiator permissions (#575)
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
1 parent 6d05ed7 commit 251bc42

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

.github/workflows/comment-commands.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ jobs:
113113
ref: 'main',
114114
inputs: {
115115
pr_number: context.issue.number.toString(),
116+
approver: context.actor,
116117
}
117118
});
118119

.github/workflows/fork-smoke-tests.yaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ on:
1414
description: 'Exact commit SHA from the fork PR to test (leave empty to use PR head)'
1515
required: false
1616
type: string
17+
approver:
18+
description: 'Username of maintainer approving this test. Auto-filled by CI (leave empty for manual runs)'
19+
required: false
20+
type: string
1721

1822
jobs:
1923
check-permissions:
@@ -26,21 +30,24 @@ jobs:
2630
uses: actions/github-script@v9
2731
with:
2832
script: |
33+
const approver = '${{ inputs.approver }}'.trim();
34+
const actorToCheck = approver || context.actor;
35+
2936
const result = await github.rest.repos.getCollaboratorPermissionLevel({
3037
owner: context.repo.owner,
3138
repo: context.repo.repo,
32-
username: context.actor,
39+
username: actorToCheck,
3340
});
3441
const allowed = ['write', 'maintain', 'admin'];
3542
const permission = result.data.permission;
3643
if (!allowed.includes(permission)) {
3744
core.setFailed(
38-
`@${context.actor} has permission '${permission}' — ` +
45+
`@${actorToCheck} has permission '${permission}' — ` +
3946
`maintainer access (write/maintain/admin) is required to run fork smoke tests.`
4047
);
4148
return;
4249
}
43-
console.log(`@${context.actor} has permission '${permission}' — proceeding.`);
50+
console.log(`@${actorToCheck} has permission '${permission}' — proceeding.`);
4451
4552
resolve-pr:
4653
needs: [check-permissions]

0 commit comments

Comments
 (0)