@@ -16,11 +16,17 @@ runs:
16
16
steps :
17
17
- uses : actions/github-script@v7
18
18
id : check-permission
19
+ env :
20
+ INPUT_MINIMUM-PERMISSION : ${{ inputs.minimum-permission }}
19
21
with :
20
22
script : |
21
23
// Valid permissions are none, read, write, admin (legacy base permissions)
22
24
const permissionsRanking = ["none", "read", "write", "admin"];
23
25
26
+ // Note: core.getInput doesn't work by default in a composite action - in this case
27
+ // it would try to fetch the input to the github-script instead of the action
28
+ // itself. Instead, we set the appropriate magic env var with the actions input.
29
+ // See: https://github.com/actions/runner/issues/665
24
30
const minimumPermission = core.getInput('minimum-permission');
25
31
if (!permissionsRanking.includes(minimumPermission)) {
26
32
core.setFailed(`Invalid minimum permission: ${minimumPermission}`);
@@ -30,14 +36,14 @@ runs:
30
36
const { data : { permission : actorPermission } } = await github.rest.repos.getCollaboratorPermissionLevel({
31
37
owner: context.repo.owner,
32
38
repo: context.repo.repo,
33
- username: tools. context.actor
39
+ username: context.actor
34
40
});
35
41
36
42
// Confirm whether the actor permission is at least the selected permission
37
43
const hasPermission = permissionsRanking.indexOf(minimumPermission) <= permissionsRanking.indexOf(actorPermission) ? "1" : "";
38
44
core.setOutput('has-permission', hasPermission);
39
45
if (!hasPermission) {
40
- core.info(`Current actor (${tools. context.actor}) does not have the minimum required permission '${minimumPermission}' (has '${actorPermission}')`);
46
+ core.info(`Current actor (${context.actor}) does not have the minimum required permission '${minimumPermission}' (has '${actorPermission}')`);
41
47
} else {
42
- core.info(`Current actor (${tools. context.actor}) has the minimum required permission '${minimumPermission}' (has '${actorPermission}')`);
43
- }
48
+ core.info(`Current actor (${context.actor}) has the minimum required permission '${minimumPermission}' (has '${actorPermission}')`);
49
+ }
0 commit comments