Skip to content

Commit d4389c4

Browse files
authored
feat: add version as build arg for mev (#244)
Signed-off-by: Barnabas Busa <busa.barnabas@gmail.com>
1 parent a8fca7b commit d4389c4

2 files changed

Lines changed: 46 additions & 7 deletions

File tree

.github/workflows/build-push-mev-boost-relay.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ on:
1717
description: Override target docker tag (defaults to the above source ref if left blank)
1818
type: string
1919
required: false
20+
build_args:
21+
description: Build arguments to pass to the docker build command
22+
type: string
23+
required: false
2024

2125
jobs:
2226
prepare:
@@ -51,6 +55,21 @@ jobs:
5155
- uses: ./.github/actions/install-deps
5256
with:
5357
repository: ${{ inputs.repository }}
58+
# Check out source repository to get commit hash
59+
- name: Check out source repository
60+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
61+
with:
62+
repository: ${{ inputs.repository }}
63+
path: source
64+
ref: ${{ inputs.ref }}
65+
fetch-depth: 0
66+
# Get the git commit hash before using it
67+
- name: Get git commit hash
68+
id: get_commit_hash
69+
run: |
70+
cd source
71+
echo "git_commit_hash=$(git log --pretty=format:'%h' -n 1 --abbrev=7)" >> $GITHUB_OUTPUT
72+
shell: bash
5473
- uses: ./.github/actions/deploy
5574
id: deploy
5675
with:
@@ -59,20 +78,20 @@ jobs:
5978
target_tag: ${{ needs.prepare.outputs.target_tag }}-${{ matrix.slug }}
6079
target_repository: ethpandaops/mev-boost-relay
6180
platform: ${{ matrix.platform }}
62-
81+
build_args: ${{ inputs.build_args || format('VERSION={0}-{1}', inputs.ref, steps.get_commit_hash.outputs.git_commit_hash) }}
6382
DOCKER_USERNAME: "${{ vars.DOCKER_USERNAME }}"
6483
DOCKER_PASSWORD: "${{ secrets.DOCKER_PASSWORD }}"
6584
MACOS_PASSWORD: "${{ secrets.MACOS_PASSWORD }}"
6685
GOPROXY: "${{ vars.GOPROXY }}"
6786
HARBOR_USERNAME: "${{ vars.HARBOR_USERNAME }}"
6887
HARBOR_PASSWORD: "${{ secrets.HARBOR_PASSWORD }}"
6988
harbor_registry: ${{ vars.HARBOR_REGISTRY }}
70-
71-
# This step captures the git commit hash from the deploy action for job output
89+
# This step captures the git commit hash for job output
7290
- name: Set job output
7391
id: set_output
74-
run: echo "git_commit_hash=${{ steps.deploy.outputs.git_commit_hash }}" >> $GITHUB_OUTPUT
92+
run: echo "git_commit_hash=${{ steps.get_commit_hash.outputs.git_commit_hash }}" >> $GITHUB_OUTPUT
7593
shell: bash
94+
7695
manifest:
7796
needs:
7897
- prepare

.github/workflows/build-push-mev-boost.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ on:
1717
description: Override target docker tag (defaults to the above source ref if left blank)
1818
type: string
1919
required: false
20+
build_args:
21+
description: Build arguments to pass to the docker build command
22+
type: string
23+
required: false
24+
default: ""
2025

2126
jobs:
2227
prepare:
@@ -51,6 +56,21 @@ jobs:
5156
- uses: ./.github/actions/install-deps
5257
with:
5358
repository: ${{ inputs.repository }}
59+
# Check out source repository to get commit hash
60+
- name: Check out source repository
61+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
62+
with:
63+
repository: ${{ inputs.repository }}
64+
path: source
65+
ref: ${{ inputs.ref }}
66+
fetch-depth: 0
67+
# Get the git commit hash before using it
68+
- name: Get git commit hash
69+
id: get_commit_hash
70+
run: |
71+
cd source
72+
echo "git_commit_hash=$(git log --pretty=format:'%h' -n 1 --abbrev=7)" >> $GITHUB_OUTPUT
73+
shell: bash
5474
- uses: ./.github/actions/deploy
5575
id: deploy
5676
with:
@@ -59,6 +79,7 @@ jobs:
5979
target_tag: ${{ needs.prepare.outputs.target_tag }}-${{ matrix.slug }}
6080
target_repository: ethpandaops/mev-boost
6181
platform: ${{ matrix.platform }}
82+
build_args: ${{ inputs.build_args || format('VERSION={0}-{1}', inputs.ref, steps.get_commit_hash.outputs.git_commit_hash) }}
6283

6384
DOCKER_USERNAME: "${{ vars.DOCKER_USERNAME }}"
6485
DOCKER_PASSWORD: "${{ secrets.DOCKER_PASSWORD }}"
@@ -67,11 +88,10 @@ jobs:
6788
HARBOR_USERNAME: "${{ vars.HARBOR_USERNAME }}"
6889
HARBOR_PASSWORD: "${{ secrets.HARBOR_PASSWORD }}"
6990
harbor_registry: ${{ vars.HARBOR_REGISTRY }}
70-
71-
# This step captures the git commit hash from the deploy action for job output
91+
# This step captures the git commit hash for job output
7292
- name: Set job output
7393
id: set_output
74-
run: echo "git_commit_hash=${{ steps.deploy.outputs.git_commit_hash }}" >> $GITHUB_OUTPUT
94+
run: echo "git_commit_hash=${{ steps.get_commit_hash.outputs.git_commit_hash }}" >> $GITHUB_OUTPUT
7595
shell: bash
7696
manifest:
7797
needs:

0 commit comments

Comments
 (0)