File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -112,6 +112,35 @@ jobs:
112112 TEST_BITBUCKET_SERVER_USER : pipelines
113113 TEST_BITBUCKET_SERVER_E2E_REPOSITORY : PAC/pac-e2e-tests
114114 steps :
115+ - name : Check user permissions (detailed)
116+ id : check_perms
117+ uses : actions/github-script@v7
118+ with :
119+ script : |
120+ const actor = context.actor;
121+ const { owner, repo } = context.repo;
122+
123+ try {
124+ const response = await github.rest.repos.getCollaboratorPermissionLevel({
125+ owner,
126+ repo,
127+ username: actor,
128+ });
129+
130+ const userPermission = response.data.permission;
131+
132+ if (userPermission === 'admin') {
133+ core.info(`✅ Permission check successful. User @${actor} is an ADMIN.`);
134+ } else if (userPermission === 'write') {
135+ core.info(`✅ Permission check successful. User @${actor} has WRITE permission.`);
136+ } else {
137+ core.setFailed(`❌ Permission check failed. User @${actor} has '${userPermission}' permission, but 'write' or 'admin' is required to proceed.`);
138+ }
139+
140+ } catch (error) {
141+ core.setFailed(`Could not verify permission for @${actor}. They might not be a collaborator. Error: ${error.message}`);
142+ }
143+
115144 - uses : actions/checkout@v5
116145 with :
117146 ref : ${{ inputs.target_ref || github.event.pull_request.head.sha || github.sha }}
You can’t perform that action at this time.
0 commit comments