From c35f67b20818711bd6f6e3b67981a011370fbcb4 Mon Sep 17 00:00:00 2001 From: Onkar Hanumante Date: Thu, 15 Feb 2024 21:22:31 +0530 Subject: [PATCH] Fix: Release workflow permissions (#3506) --- .github/workflows/helpers/pull-request-utils.js | 4 ++-- .github/workflows/release.yml | 10 +--------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/.github/workflows/helpers/pull-request-utils.js b/.github/workflows/helpers/pull-request-utils.js index 8b470618170..73c80396473 100644 --- a/.github/workflows/helpers/pull-request-utils.js +++ b/.github/workflows/helpers/pull-request-utils.js @@ -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 } /* @@ -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 } } diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 92d6a589e6a..d3559732077 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 @@ -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