Skip to content

Commit

Permalink
Fix: Release workflow permissions (prebid#3506)
Browse files Browse the repository at this point in the history
  • Loading branch information
onkarvhanumante authored Feb 15, 2024
1 parent 902d262 commit c35f67b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/helpers/pull-request-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ class userHelper {
this.owner = input.context.repo.owner
this.repo = input.context.repo.repo
this.github = input.github
this.user = input.user
}

/*
Expand All @@ -424,9 +425,8 @@ class userHelper {
const { data } = await this.github.rest.repos.getCollaboratorPermissionLevel({
owner: this.owner,
repo: this.repo,
username: this.owner,
username: this.user,
})
console.log(JSON.stringify(data))
return data.permission === writePermission || data.permission === adminPermission
}
}
Expand Down
10 changes: 1 addition & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,11 @@ jobs:
result-encoding: string
script: |
const utils = require('./.github/workflows/helpers/pull-request-utils.js')
const helper = utils.userHelper({github, context})
const helper = utils.userHelper({github, context, user: '${{ github.actor }}'})
const hasPermission = await helper.hasWritePermissions()
return hasPermission
outputs:
hasWritePermission: ${{ steps.check.outputs.result }}

debug-step:
name: Debug step
runs-on: ubuntu-latest
steps:
- name: Debug
run: echo ${{ needs.check-permission.outputs.hasWritePermission }}

build-master:
name: Build master
Expand All @@ -71,7 +64,6 @@ jobs:
publish-tag:
name: Publish tag
needs: build-master
if: contains(needs.check-permission.outputs.hasWritePermission, 'true')
permissions:
contents: write
runs-on: ubuntu-latest
Expand Down

0 comments on commit c35f67b

Please sign in to comment.