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 6868 TEST_BITBUCKET_SERVER_USER : pipelines
6969 TEST_BITBUCKET_SERVER_E2E_REPOSITORY : PAC/pac-e2e-tests
7070 steps :
71+ - name : Check user permissions (detailed)
72+ id : check_perms
73+ uses : actions/github-script@v7
74+ with :
75+ script : |
76+ const actor = context.actor;
77+ const { owner, repo } = context.repo;
78+
79+ try {
80+ const response = await github.rest.repos.getCollaboratorPermissionLevel({
81+ owner,
82+ repo,
83+ username: actor,
84+ });
85+
86+ const userPermission = response.data.permission;
87+
88+ if (userPermission === 'admin') {
89+ core.info(`✅ Permission check successful. User @${actor} is an ADMIN.`);
90+ } else if (userPermission === 'write') {
91+ core.info(`✅ Permission check successful. User @${actor} has WRITE permission.`);
92+ } else {
93+ core.setFailed(`❌ Permission check failed. User @${actor} has '${userPermission}' permission, but 'write' or 'admin' is required to proceed.`);
94+ }
95+
96+ } catch (error) {
97+ core.setFailed(`Could not verify permission for @${actor}. They might not be a collaborator. Error: ${error.message}`);
98+ }
99+
71100 - uses : actions/checkout@v5
72101 with :
73102 ref : ${{ inputs.target_ref || github.event.pull_request.head.sha || github.sha }}
You can’t perform that action at this time.
0 commit comments