diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 21014f029c452f..29e9c225966983 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -97,6 +97,25 @@ jobs: with: version: 8 + - name: Fetch PR details (if PR number provided) + if: github.event.inputs.pr + id: pr_details + uses: actions/github-script@v6 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const pr = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: ${{ github.event.inputs.pr }}, + }); + return pr.data.head.ref; + + - name: Checkout + uses: actions/checkout@v3 + with: + ref: ${{ steps.pr_details.outputs.result || 'master' }} # Default to master branch if PR number not provided + - name: Setup node uses: actions/setup-node@v4 if: ${{ !matrix.settings.docker }}