1212 IMAGE_NAME : ${{ github.repository }}
1313
1414jobs :
15- build :
15+ build-and-push :
1616 runs-on : ubuntu-latest
17- strategy :
18- matrix :
19- platform : [linux/amd64, linux/arm64]
2017 permissions :
2118 contents : read
2219 packages : write
@@ -32,21 +29,13 @@ jobs:
3229 id : buildx
3330
3431 - name : Log in to the Container registry
35- # Only login if we're pushing (not a PR)
3632 if : github.event_name != 'pull_request'
3733 uses : docker/login-action@v3
3834 with :
3935 registry : ${{ env.REGISTRY }}
4036 username : ${{ github.actor }}
4137 password : ${{ secrets.GITHUB_TOKEN }}
4238
43- - name : Extract platform short name
44- id : platform
45- run : |
46- # Extract the architecture from the platform (e.g., amd64 from linux/amd64)
47- ARCH=$(echo "${{ matrix.platform }}" | cut -d/ -f2)
48- echo "arch=${ARCH}" >> $GITHUB_OUTPUT
49-
5039 - name : Extract metadata (tags, labels) for Docker
5140 id : meta
5241 uses : docker/metadata-action@v5
6352 uses : docker/build-push-action@v5
6453 with :
6554 context : .
66- # Only push if not a PR
6755 push : ${{ github.event_name != 'pull_request' }}
68- platforms : ${{ matrix.platform }}
69- tags : ${{ steps.meta.outputs.tags }}-${{ steps.platform.outputs.arch }}
56+ platforms : linux/amd64,linux/arm64
57+ tags : ${{ steps.meta.outputs.tags }}
7058 labels : ${{ steps.meta.outputs.labels }}
7159 cache-from : type=gha
72- cache-to : type=gha,mode=max
73-
74- create-manifest :
75- # Skip this job for pull requests
76- if : github.event_name != 'pull_request'
77- runs-on : ubuntu-latest
78- needs : build
79- permissions :
80- contents : read
81- packages : write
82- steps :
83- - name : Set up Docker Buildx
84- uses : docker/setup-buildx-action@v3
85-
86- - name : Log in to the Container registry
87- uses : docker/login-action@v3
88- with :
89- registry : ${{ env.REGISTRY }}
90- username : ${{ github.actor }}
91- password : ${{ secrets.GITHUB_TOKEN }}
92-
93- - name : Extract metadata (tags, labels) for Docker
94- id : meta
95- uses : docker/metadata-action@v5
96- with :
97- images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
98- tags : |
99- type=ref,event=branch
100- type=ref,event=pr
101- type=semver,pattern={{version}}
102- type=semver,pattern={{major}}.{{minor}}
103- type=sha,format=long
104-
105- - name : Create manifest lists and push
106- run : |
107- # Process each tag and create a manifest for it
108- echo "${{ steps.meta.outputs.tags }}" | while read -r TAG; do
109- if [ -n "$TAG" ]; then
110- echo "Creating manifest for $TAG"
111- docker buildx imagetools create \
112- --tag $TAG \
113- $TAG-amd64 \
114- $TAG-arm64
115- fi
116- done
117-
118- - name : Inspect images
119- run : |
120- echo "${{ steps.meta.outputs.tags }}" | while read -r TAG; do
121- if [ -n "$TAG" ]; then
122- echo "Inspecting manifest for $TAG"
123- docker buildx imagetools inspect $TAG
124- fi
125- done
60+ cache-to : type=gha,mode=max
0 commit comments