diff --git a/.github/workflows/build-cli.yml b/.github/workflows/build-cli.yml index d0956aff4b59..a684d0f672f5 100644 --- a/.github/workflows/build-cli.yml +++ b/.github/workflows/build-cli.yml @@ -9,6 +9,10 @@ on: required: false default: "" type: string + pr_number: + required: false + default: "" + type: string # Let's allow overriding the OSes and architectures in JSON array form: # e.g. '["ubuntu-latest","macos-latest"]' # If no input is provided, these defaults apply. @@ -39,8 +43,26 @@ jobs: target-suffix: apple-darwin steps: + - name: Get PR details + if: ${{ inputs.pr_number != '' }} + id: pr + uses: actions/github-script@v7 + with: + script: | + const pr = await github.rest.pulls.get({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: ${{ inputs.pr_number }} + }); + core.setOutput('head_ref', pr.data.head.ref); + core.setOutput('head_sha', pr.data.head.sha); + core.setOutput('head_repo', pr.data.head.repo.full_name); + - name: Checkout code uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # pin@v4 + with: + ref: ${{ inputs.pr_number != '' && steps.pr.outputs.head_sha || github.sha }} + repository: ${{ inputs.pr_number != '' && steps.pr.outputs.head_repo || github.repository }} - name: Update version in Cargo.toml if: ${{ inputs.version != '' }} diff --git a/.github/workflows/pr-comment-build-cli.yml b/.github/workflows/pr-comment-build-cli.yml index e4042c06a3a4..d47ec7f124cd 100644 --- a/.github/workflows/pr-comment-build-cli.yml +++ b/.github/workflows/pr-comment-build-cli.yml @@ -41,6 +41,8 @@ jobs: needs: [trigger-on-command] if: ${{ needs.trigger-on-command.outputs.continue == 'true' }} uses: ./.github/workflows/build-cli.yml + with: + pr_number: ${{ needs.trigger-on-command.outputs.pr_number }} pr-comment-cli: name: PR Comment with CLI builds