Skip to content

Commit acd6106

Browse files
authored
build args (#8)
* update changelog * add build args and run multiplatform builds * address PR feedback
1 parent e9ba86a commit acd6106

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

.github/workflows/build.yml

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,22 @@ jobs:
5656
run: |
5757
echo "registry=$(echo '${{ steps.build-meta.outputs.tags }}' | cut -f1 -d:)" | tee -a "$GITHUB_OUTPUT"
5858
59+
- id: set_build_url
60+
name: Set BUILD_URL
61+
run: |
62+
echo "build_url=${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" | tee -a "$GITHUB_OUTPUT"
63+
5964
- id: build
6065
name: Build/push the arch-specific image
6166
uses: docker/build-push-action@v6
6267
with:
68+
platforms: ${{ matrix.platform }}
69+
build-args: |
70+
BUILD_TIMESTAMP=${{ github.event.repository.updated_at }}
71+
BUILD_URL=${{ steps.set_build_url.outputs.build_url }}
72+
GIT_REF_NAME=${{ github.ref_name }}
73+
GIT_SHA=${{ github.sha }}
74+
GIT_REPOSITORY_URL=${{ github.repositoryUrl }}
6375
cache-from: type=registry,ref=${{ steps.cache-meta.outputs.tags }}
6476
cache-to: type=registry,ref=${{ steps.cache-meta.outputs.tags }},mode=max
6577
labels: ${{ steps.build-meta.outputs.labels }}
@@ -74,13 +86,15 @@ jobs:
7486
echo "image-${RUNNER_ARCH,,}=${{ steps.get-registry.outputs.registry }}@${{ steps.build.outputs.digest }}" | tee -a "$GITHUB_OUTPUT"
7587
7688
merge:
77-
runs-on: ubuntu-24.04
89+
runs-on: ubuntu-latest
7890
needs: build
7991
env:
8092
DOCKER_APP_IMAGE_ARM64: ${{ needs.build.outputs.image-arm64 }}
8193
DOCKER_APP_IMAGE_X64: ${{ needs.build.outputs.image-x64 }}
8294
outputs:
8395
image: ${{ steps.meta.outputs.tags }}
96+
build-image-arm: ${{ needs.build.outputs.image-arm64 }}
97+
build-image-x64: ${{ needs.build.outputs.image-x64 }}
8498
steps:
8599
- name: Checkout code
86100
uses: actions/checkout@v4
@@ -109,7 +123,7 @@ jobs:
109123
"$DOCKER_APP_IMAGE_ARM64" "$DOCKER_APP_IMAGE_X64"
110124
111125
test:
112-
runs-on: ubuntu-24.04
126+
runs-on: ubuntu-latest
113127
needs: merge
114128
env:
115129
COMPOSE_FILE: docker-compose.yml:docker-compose.ci.yml
@@ -157,17 +171,19 @@ jobs:
157171
if: ${{ always() }}
158172
uses: actions/upload-artifact@v4
159173
with:
160-
name: Build Report (${{ github.run_id }}_${{ github.run_attempt }})
174+
name: UCBEARS Test Report (${{ github.run_id }}_${{ github.run_attempt }})
161175
path: artifacts/*
162176
if-no-files-found: error
163177

164178
push:
165-
runs-on: ubuntu-24.04
179+
runs-on: ubuntu-latest
166180
needs:
167181
- merge
168182
- test
169183
env:
170184
DOCKER_APP_IMAGE: ${{ needs.merge.outputs.image }}
185+
DOCKER_APP_IMAGE_ARM64: ${{ needs.merge.outputs.build-image-arm }}
186+
DOCKER_APP_IMAGE_X64: ${{ needs.merge.outputs.build-image-x64 }}
171187
steps:
172188
- name: Checkout code
173189
uses: actions/checkout@v4
@@ -190,6 +206,6 @@ jobs:
190206
191207
- name: Retag and push the image
192208
run: |
193-
docker pull "$DOCKER_APP_IMAGE"
194-
echo "$DOCKER_METADATA_OUTPUT_TAGS" | tr ' ' '\n' | xargs -n1 docker tag "$DOCKER_APP_IMAGE"
195-
docker push --all-tags "$(echo "$DOCKER_APP_IMAGE" | cut -f1 -d:)"
209+
docker buildx imagetools create \
210+
$(jq -cr '.tags | map("--tag " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
211+
$DOCKER_APP_IMAGE_ARM64 $DOCKER_APP_IMAGE_X64

.github/workflows/release.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
env:
3838
BASE_IMAGE: ${{ steps.get-base-image.outputs.tags }}
3939
run: |
40-
docker pull "$BASE_IMAGE"
40+
docker manifest inspect "$BASE_IMAGE"
4141
4242
- name: Produce release tags
4343
id: tag-meta
@@ -51,9 +51,11 @@ jobs:
5151
type=semver,pattern={{major}}.{{minor}}
5252
type=semver,pattern={{version}}
5353
54+
5455
- name: Retag the pulled image
5556
env:
5657
BASE_IMAGE: ${{ steps.get-base-image.outputs.tags }}
5758
run: |
58-
echo "$DOCKER_METADATA_OUTPUT_TAGS" | tr ' ' '\n' | xargs -n1 docker tag "$BASE_IMAGE"
59-
docker push --all-tags "$(echo "$BASE_IMAGE" | cut -f1 -d:)"
59+
docker buildx imagetools create \
60+
"$(jq -cr '.tags | map("--tag " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON")" \
61+
"$(echo "$BASE_IMAGE" | cut -f1 -d:)"

0 commit comments

Comments
 (0)