Skip to content

Commit b321cfe

Browse files
committed
chore: Enhance Docker tag resolution by using environment variables for improved clarity
1 parent 69e3b44 commit b321cfe

File tree

1 file changed

+29
-23
lines changed

1 file changed

+29
-23
lines changed

.github/workflows/build-docker-images.yml

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,13 @@ jobs:
112112
steps:
113113
- name: Check if should skip (ARM64)
114114
id: should_skip
115+
env:
116+
MATRIX_NAME: ${{ matrix.name }}
117+
SKIP_ARM64: ${{ inputs.skip_arm64 }}
115118
run: |
116119
SKIP="false"
117120
# Skip ARM64 builds if requested
118-
if [[ "${{ matrix.name }}" == "linux-arm64" && "${{ inputs.skip_arm64 }}" == "true" ]]; then
121+
if [[ "$MATRIX_NAME" == "linux-arm64" && "$SKIP_ARM64" == "true" ]]; then
119122
SKIP="true"
120123
fi
121124
echo "skip=$SKIP" >> $GITHUB_OUTPUT
@@ -151,35 +154,38 @@ jobs:
151154
dockerfile: 'Dockerfile'
152155
cache-hit: '${{ steps.setup-java.outputs.cache-hit }}'
153156

154-
- name: Resolve Docker tag (publish amd64)
155-
if: steps.should_skip.outputs.skip != 'true' && matrix.docker_tag_input == 'tags_publish_amd64'
156-
id: resolve_tag_1
157-
run: |
158-
echo "tag=${{ inputs.tags_publish_amd64 }}" >> $GITHUB_OUTPUT
159-
- name: Resolve Docker tag (publish arm64)
160-
if: steps.should_skip.outputs.skip != 'true' && matrix.docker_tag_input == 'tags_publish_arm64'
161-
id: resolve_tag_2
162-
run: |
163-
echo "tag=${{ inputs.tags_publish_arm64 }}" >> $GITHUB_OUTPUT
164-
- name: Resolve Docker tag (minimal amd64)
165-
if: steps.should_skip.outputs.skip != 'true' && matrix.docker_tag_input == 'tags_minimal_amd64'
166-
id: resolve_tag_3
167-
run: |
168-
echo "tag=${{ inputs.tags_minimal_amd64 }}" >> $GITHUB_OUTPUT
169-
- name: Resolve Docker tag (minimal arm64)
170-
if: steps.should_skip.outputs.skip != 'true' && matrix.docker_tag_input == 'tags_minimal_arm64'
171-
id: resolve_tag_4
157+
- name: Resolve Docker tag
158+
if: steps.should_skip.outputs.skip != 'true'
159+
id: resolve_tag
160+
env:
161+
TAG_INPUT: ${{ matrix.docker_tag_input }}
162+
TAGS_PUBLISH_AMD64: ${{ inputs.tags_publish_amd64 }}
163+
TAGS_PUBLISH_ARM64: ${{ inputs.tags_publish_arm64 }}
164+
TAGS_MINIMAL_AMD64: ${{ inputs.tags_minimal_amd64 }}
165+
TAGS_MINIMAL_ARM64: ${{ inputs.tags_minimal_arm64 }}
172166
run: |
173-
echo "tag=${{ inputs.tags_minimal_arm64 }}" >> $GITHUB_OUTPUT
167+
case "$TAG_INPUT" in
168+
tags_publish_amd64) TAG="$TAGS_PUBLISH_AMD64" ;;
169+
tags_publish_arm64) TAG="$TAGS_PUBLISH_ARM64" ;;
170+
tags_minimal_amd64) TAG="$TAGS_MINIMAL_AMD64" ;;
171+
tags_minimal_arm64) TAG="$TAGS_MINIMAL_ARM64" ;;
172+
*) TAG="local/openrouteservice:test" ;;
173+
esac
174+
echo "tag=$TAG" >> $GITHUB_OUTPUT
174175
175176
- name: Determine Docker output
176177
if: steps.should_skip.outputs.skip != 'true'
177178
id: output
179+
env:
180+
PUSH: ${{ inputs.push }}
181+
RUNNER_TEMP: ${{ runner.temp }}
182+
MATRIX_NAME: ${{ matrix.name }}
183+
MATRIX_STAGE: ${{ matrix.image_stage }}
178184
run: |
179-
if [ "${{ inputs.push }}" == "true" ]; then
185+
if [ "$PUSH" == "true" ]; then
180186
echo "output=type=image,push=true" >> $GITHUB_OUTPUT
181187
else
182-
echo "output=type=docker,dest=${{ runner.temp }}/image-${{ matrix.name }}-${{ matrix.image_stage }}.tar" >> $GITHUB_OUTPUT
188+
echo "output=type=docker,dest=$RUNNER_TEMP/image-$MATRIX_NAME-$MATRIX_STAGE.tar" >> $GITHUB_OUTPUT
183189
fi
184190
185191
- name: Build ${{ matrix.image_stage }} image stage for ${{ matrix.name }}
@@ -191,7 +197,7 @@ jobs:
191197
target: ${{ matrix.image_stage }}
192198
push: ${{ inputs.push }}
193199
load: false
194-
tags: ${{ steps.resolve_tag_1.outputs.tag || steps.resolve_tag_2.outputs.tag || steps.resolve_tag_3.outputs.tag || steps.resolve_tag_4.outputs.tag || 'local/openrouteservice:test' }}
200+
tags: ${{ steps.resolve_tag.outputs.tag }}
195201
platforms: "${{ matrix.platform }}"
196202
cache-from: type=${{ inputs.cache_from_type }}
197203
cache-to: type=${{ inputs.cache_from_type }},mode=max

0 commit comments

Comments
 (0)