Skip to content

Commit 3294df1

Browse files
authored
Move prod image to use metadata-action (#1713)
1 parent cd79871 commit 3294df1

File tree

1 file changed

+20
-48
lines changed

1 file changed

+20
-48
lines changed

.github/workflows/build_production_image.yml

Lines changed: 20 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,6 @@
22
name: Build Production Image
33

44
on:
5-
workflow_dispatch:
6-
inputs:
7-
branch:
8-
description: 'Git Reference to Build Into an Image'
9-
required: true
10-
default: trunk
11-
repo:
12-
description: 'Docker Repo to Push Image To'
13-
required: true
14-
tag:
15-
description: 'Name for Image'
16-
required: false
17-
default: edge
185
push:
196
branches: 'trunk'
207
tags: 'v*.*.*' #all version tags
@@ -29,6 +16,11 @@ jobs:
2916
-
3017
name: Set up Docker Buildx
3118
uses: docker/setup-buildx-action@v3
19+
-
20+
name: Set up just
21+
uses: extractions/setup-just@v3
22+
with:
23+
just-version: 1.26.0
3224
-
3325
name: Login to DockerHub
3426
uses: docker/login-action@v3
@@ -43,41 +35,21 @@ jobs:
4335
fetch-depth: 0
4436
ref: ${{ github.event.inputs.branch }}
4537
-
46-
name: Determine Image Tags
47-
id: generate_tag
48-
run: |
49-
# this part is just a copy of just prep-version
50-
# TODO: transfer building of the production image to a just recipe
51-
git fetch --tags && git describe --tags | cut -f 1 -d '-' > VERSION
52-
source ${GITHUB_WORKSPACE}/.github/actions/common.sh
53-
_tags=""
54-
if [[ $GITHUB_EVENT_NAME == "workflow_dispatch" ]]; then
55-
_repo=${{ github.event.inputs.repo }}
56-
_input_tag=${{ github.event.inputs.tag }}
57-
if [[ ${_repo} == "ldmx/pro" ]]; then
58-
error "Provided 'ldmx/pro' repo on non-trunk branch."
59-
exit 1
60-
fi
61-
_tags="${_repo}:${_input_tag},${_repo}:sha-${GITHUB_SHA::8}"
62-
elif [[ $GITHUB_REF == refs/tags/* ]]; then
63-
# if pushing a git tag ==> get the git tag for the docker tag
64-
_git_tag=${GITHUB_REF#refs/tags/}
65-
_tags="ldmx/pro:$_git_tag"
66-
if [[ $_git_tag =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
67-
# there was a version released on github
68-
# v<1-3 digits>.<1-3 digits>.<1-3 digits>
69-
_tags="$_tags,ldmx/pro:latest"
70-
fi
71-
elif [[ $GITHUB_REF == refs/heads/* ]]; then
72-
#pushing to trunk
73-
_tags="ldmx/pro:edge,ldmx/pro:sha-${GITHUB_SHA::8}"
74-
else
75-
error "Running Determine Image Tags on a commit that isn't a tag or a branch."
76-
exit 1
77-
fi
78-
set_output tags ${_tags}
79-
set_output should_push ${_should_push}
80-
shell: bash
38+
name: Docker meta
39+
id: meta
40+
uses: docker/metadata-action@v5
41+
with:
42+
# Default image name for push actions
43+
images: ${{ 'ldmx/pro' }}
44+
tags: |
45+
type=ref,event=branch
46+
type=ref,event=pr
47+
type=semver,pattern=v{{version}}
48+
type=sha,format=short
49+
50+
-
51+
name: Update version variable before building
52+
run: just prep-version
8153
-
8254
name: Build the Image
8355
id: docker_build

0 commit comments

Comments
 (0)