diff --git a/.github/workflows/package-publish.yml b/.github/workflows/package-publish.yml index b97ddcbb5..ce38904e2 100644 --- a/.github/workflows/package-publish.yml +++ b/.github/workflows/package-publish.yml @@ -27,6 +27,33 @@ jobs: with: node-version: 18.x cache: 'yarn' + - name: 'validation' + uses: actions/github-script@v7 + with: + script: | + const permission = await github.rest.repos.getCollaboratorPermissionLevel({ + owner: context.repo.owner, + repo: context.repo.repo, + username: context.actor + }); + if (permission.data.permission !== 'admin' && permission.data.permission !== 'write') { + core.setFailed(`User ${context.actor} does not have write or admin permissions to this repository.`); + } + const currentBranch = context.ref.replace('refs/heads/', ''); + if (currentBranch !== `release/v${{ github.event.inputs.version }}`) { + core.setFailed(`Current branch ${currentBranch} does not match release/v${{ github.event.inputs.version }}`); + } + const pullRequests = await github.rest.pulls.list({ + owner: context.repo.owner, + repo: context.repo.repo, + state: 'open', + sort: 'created', + direction: 'desc', + }); + const pr = pullRequests.data.find(pr => pr.head.ref === currentBranch && pr.base.ref === 'develop'); + if (!pr) { + core.setFailed(`No open pull request found for ${currentBranch} to develop`); + } - name: Check if the release branch exists run: | set -x