Skip to content

Commit 4f31527

Browse files
committed
Docker push with buildx
1 parent e9f24fb commit 4f31527

1 file changed

Lines changed: 20 additions & 22 deletions

File tree

.github/workflows/reusable-container-publication.yml

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -107,41 +107,39 @@ jobs:
107107
repository: devpro/github-workflow-parts
108108
ref: ${{ inputs.workflow-parts-version }}
109109
path: workflow-parts
110-
- name: Set up QEMU
111-
uses: docker/setup-qemu-action@v4
112-
- name: Set up Buildx
113-
uses: docker/setup-buildx-action@v4
114110
- name: Login to container registry
115111
uses: docker/login-action@v4
116112
with:
117113
registry: ${{ inputs.container-registry }}
118114
username: ${{ secrets.container-registry-username }}
119115
password: ${{ secrets.container-registry-password }}
120-
- name: Build container image
121-
run: |
122-
docker buildx build . \
123-
--file ${{ inputs.image-definition }} \
124-
--tag ${{ env.IMAGE_REF }} \
125-
--platform ${{ inputs.image-platform }} \
126-
${{ inputs.extra-build-arguments }}
127-
shell: bash
116+
- name: Set up QEMU
117+
uses: docker/setup-qemu-action@v4
118+
- name: Set up Buildx
119+
uses: docker/setup-buildx-action@v4
120+
- name: Build and push container image
121+
id: build-push
122+
uses: docker/build-push-action@v7
123+
with:
124+
context: ${{ inputs.working-directory }}
125+
file: ${{ inputs.image-definition }}
126+
platforms: ${{ inputs.image-platform }}
127+
push: true
128+
tags: ${{ env.IMAGE_REF }}
129+
cache-from: type=gha
130+
cache-to: type=gha,mode=max
131+
build-args: ${{ inputs.extra-build-arguments }}
128132
- name: Generate SBOM with Syft
129133
uses: anchore/sbom-action@v0
130134
continue-on-error: true
131135
with:
132136
image: ${{ env.IMAGE_REF }}
133-
# format: spdx-json # Or cyclonedx-json
134-
# output-file: sbom.json
135-
# upload-artifact: true # Auto-upload to workflow artifacts
136-
- name: Push image to container registry
137-
run: docker push ${{ env.IMAGE_REF }}
138-
shell: bash
139-
- name: Push latest tag to container registry
137+
- name: Push latest tag
140138
if: ${{ inputs.create-latest }}
141139
run: |
142-
docker tag ${{ env.IMAGE_REF }} ${{ env.IMAGE_REF_LATEST }}
143-
docker push ${{ env.IMAGE_REF_LATEST }}
144-
shell: bash
140+
docker buildx imagetools create \
141+
--tag ${{ env.IMAGE_REF_LATEST }} \
142+
${{ env.IMAGE_REF }}
145143
- name: Sign container image with Cosign
146144
uses: ./workflow-parts/actions/cosign/sign
147145
with:

0 commit comments

Comments
 (0)