99 description : " The branch or tag to use as the Docker image tag (optional)."
1010 required : false
1111 default : " "
12+ pr-number :
13+ description : " PR number to build (e.g., 2283). If specified, creates tag pr-{number} and does not update latest."
14+ required : false
15+ default : " "
1216 push :
1317 branches :
1418 - devnet-ready
@@ -25,6 +29,7 @@ permissions:
2529 packages : write
2630 actions : read
2731 security-events : write
32+ pull-requests : read
2833
2934jobs :
3035 setup :
@@ -34,22 +39,52 @@ jobs:
3439 ref : ${{ steps.vars.outputs.ref }}
3540 latest_tag : ${{ steps.vars.outputs.latest_tag }}
3641 steps :
42+ - name : Get PR branch (if pr-number is specified)
43+ id : pr-info
44+ if : ${{ github.event.inputs.pr-number != '' }}
45+ uses : actions/github-script@v7
46+ with :
47+ script : |
48+ const prNumber = '${{ github.event.inputs.pr-number }}';
49+ const { data: pr } = await github.rest.pulls.get({
50+ owner: context.repo.owner,
51+ repo: context.repo.repo,
52+ pull_number: parseInt(prNumber)
53+ });
54+ core.setOutput('head_ref', pr.head.ref);
55+ core.setOutput('head_sha', pr.head.sha);
56+
3757 - name : Determine Docker tag and ref
3858 id : vars
3959 run : |
4060 if [[ "${{ github.event_name }}" == "pull_request" ]]; then
4161 echo "ref=${{ github.head_ref }}" >> $GITHUB_OUTPUT
4262 echo "tag=${{ github.base_ref }}" >> $GITHUB_OUTPUT
63+ elif [[ -n "${{ github.event.inputs.pr-number }}" ]]; then
64+ # PR build mode: use pr-{number} as tag, don't update latest
65+ pr_number="${{ github.event.inputs.pr-number }}"
66+ tag="pr-${pr_number}"
67+ echo "tag=$tag" >> $GITHUB_OUTPUT
68+
69+ # Use branch from PR info if available, otherwise use branch-or-tag input
70+ if [[ -n "${{ steps.pr-info.outputs.head_ref }}" ]]; then
71+ echo "ref=${{ steps.pr-info.outputs.head_ref }}" >> $GITHUB_OUTPUT
72+ elif [[ -n "${{ github.event.inputs.branch-or-tag }}" ]]; then
73+ echo "ref=${{ github.event.inputs.branch-or-tag }}" >> $GITHUB_OUTPUT
74+ else
75+ echo "ref=main" >> $GITHUB_OUTPUT
76+ fi
77+ echo "latest_tag=false" >> $GITHUB_OUTPUT
4378 else
4479 tag="${{ github.event.inputs.branch-or-tag || github.ref_name }}"
45- echo "ref=${{ github.ref_name }}" >> $GITHUB_OUTPUT
80+ echo "ref=${{ github.event.inputs.branch-or-tag || github. ref_name }}" >> $GITHUB_OUTPUT
4681 echo "tag=$tag" >> $GITHUB_OUTPUT
47- fi
48-
49- if [[ "$tag" != "devnet-ready" ]]; then
50- echo "latest_tag=true" >> $GITHUB_OUTPUT
51- else
52- echo "latest_tag=false" >> $GITHUB_OUTPUT
82+
83+ if [[ "$tag" != "devnet-ready" ]]; then
84+ echo "latest_tag=true" >> $GITHUB_OUTPUT
85+ else
86+ echo "latest_tag=false" >> $GITHUB_OUTPUT
87+ fi
5388 fi
5489
5590 # build artifacts for fast-runtime and non-fast-runtime
0 commit comments