Skip to content

Commit 6c70801

Browse files
author
Théo LAGACHE
committed
fix
1 parent 04e2d5a commit 6c70801

File tree

2 files changed

+32
-46
lines changed

2 files changed

+32
-46
lines changed

.github/workflows/docker.yml

Lines changed: 31 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ on:
2727

2828
jobs:
2929
build:
30-
name: Build and push Docker images
31-
runs-on: ${{ matrix.platform == 'linux/amd64' && 'ubuntu-latest' || matrix.platform == 'linux/arm64' && 'ubuntu-24.04-arm' }}
30+
name: Build architectures
31+
runs-on: ${{ matrix.platform == 'linux/amd64' && 'ubuntu-latest' || 'ubuntu-24.04-arm' }}
3232
strategy:
3333
fail-fast: false
3434
matrix:
@@ -38,21 +38,17 @@ jobs:
3838
uses: actions/checkout@v4
3939

4040
- name: Login to Docker
41-
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
41+
uses: docker/login-action@v3
4242
with:
4343
username: ${{ secrets.DOCKER_USERNAME }}
4444
password: ${{ secrets.DOCKER_PASSWORD }}
4545

46-
- name: Set image tag
47-
id: set-tags
46+
- name: Prepare Image Tags
47+
id: prep
4848
run: |
49-
REF_NAME=${GITHUB_REF#refs/tags/}
50-
if [ "${{ matrix.platform }}" = "linux/amd64" ]; then
51-
IMAGE="${{ inputs.image_name }}:$REF_NAME-amd64"
52-
else
53-
IMAGE="${{ inputs.image_name }}:$REF_NAME-arm64"
54-
fi
55-
echo "image=$IMAGE" >> $GITHUB_OUTPUT
49+
ARCH=${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
50+
echo "image=${{ inputs.image_name }}:${GITHUB_REF#refs/tags/}-$ARCH" >> $GITHUB_OUTPUT
51+
echo "safe_platform=${{ matrix.platform == 'linux/amd64' && 'linux-amd64' || 'linux-arm64' }}" >> $GITHUB_OUTPUT
5652
5753
- name: Build and push image
5854
uses: docker/build-push-action@v6
@@ -61,64 +57,53 @@ jobs:
6157
file: ${{ inputs.dockerfile }}
6258
platforms: ${{ matrix.platform }}
6359
push: true
64-
tags: ${{ steps.set-tags.outputs.image }}
60+
tags: ${{ steps.prep.outputs.image }}
6561
target: ${{ inputs.target }}
6662

67-
- name: Prepare artifact name
68-
id: artifact
69-
run: |
70-
platform=${{ matrix.platform }}
71-
echo "safe_platform=${platform//\//-}" >> $GITHUB_OUTPUT
72-
echo "${{ steps.set-tags.outputs.image }}" > image.txt
63+
- name: Save image name for manifest
64+
run: echo "${{ steps.prep.outputs.image }}" > image.txt
7365

74-
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f
66+
- uses: actions/upload-artifact@v4
7567
with:
76-
name: image-${{ steps.artifact.outputs.safe_platform }}
68+
name: image-${{ steps.prep.outputs.safe_platform }}
7769
path: image.txt
78-
if-no-files-found: warn
79-
compression-level: 6
80-
overwrite: false
81-
include-hidden-files: false
70+
retention-days: 1
8271

8372
create-manifest:
84-
name: Create multi-arch Docker manifest (Portabase)
73+
name: Create multi-arch manifest
8574
runs-on: ubuntu-latest
8675
needs: build
8776
steps:
88-
- uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131
77+
- uses: actions/download-artifact@v4
8978
with:
9079
name: image-linux-amd64
9180
path: /tmp/digests/amd64
9281

93-
- uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131
82+
- uses: actions/download-artifact@v4
9483
with:
9584
name: image-linux-arm64
9685
path: /tmp/digests/arm64
9786

9887
- name: Login to Docker
99-
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
88+
uses: docker/login-action@v3
10089
with:
10190
username: ${{ secrets.DOCKER_USERNAME }}
10291
password: ${{ secrets.DOCKER_PASSWORD }}
10392

93+
- name: Extract Docker metadata
94+
id: meta
95+
uses: docker/metadata-action@v5
96+
with:
97+
images: ${{ inputs.image_name }}
98+
tags: |
99+
type=semver,pattern={{version}}
100+
type=semver,pattern={{major}}.{{minor}}
101+
type=semver,pattern={{major}}
102+
type=raw,value=latest,enable=${{ inputs.add_latest }}
103+
104104
- name: Create and push manifest list
105105
working-directory: /tmp/digests
106106
run: |
107107
DOCKER_IMAGES="$(cat amd64/image.txt) $(cat arm64/image.txt)"
108-
REF_NAME=${GITHUB_REF#refs/tags/}
109-
MANIFEST_IMAGE="${{ inputs.image_name }}:$REF_NAME"
110-
111-
TAG_ARGS=(-t "$MANIFEST_IMAGE")
112-
if [[ "$REF_NAME" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
113-
MAJOR="${BASH_REMATCH[1]}"
114-
MINOR="${BASH_REMATCH[2]}"
115-
TAG_ARGS+=(-t "${{ inputs.image_name }}:${MAJOR}.${MINOR}" -t "${{ inputs.image_name }}:${MAJOR}")
116-
fi
117-
118-
docker buildx imagetools create $DOCKER_IMAGES "${TAG_ARGS[@]}"
119-
docker buildx imagetools inspect $MANIFEST_IMAGE
120-
121-
if [ "${{ inputs.add_latest }}" = "true" ]; then
122-
docker buildx imagetools create $DOCKER_IMAGES -t ${{ inputs.image_name }}:latest
123-
docker buildx imagetools inspect ${{ inputs.image_name }}:latest
124-
fi
108+
TAG_ARGS=$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON")
109+
docker buildx imagetools create $DOCKER_IMAGES $TAG_ARGS

.github/workflows/pr-checker.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
pull_request:
55
branches:
66
- main
7+
- dev
78

89
jobs:
910
dry-run:

0 commit comments

Comments
 (0)