Skip to content

Commit e9f24fb

Browse files
committed
Add image platform in container publication
1 parent 62dbf6e commit e9f24fb

1 file changed

Lines changed: 24 additions & 9 deletions

File tree

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

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ on:
4242
description: Image tag
4343
type: string
4444
required: true
45+
image-platform:
46+
description: Image platform
47+
type: string
48+
required: false
49+
default: "linux/amd64,linux/arm64"
4550
job-name:
4651
description: Job name
4752
type: string
@@ -69,7 +74,7 @@ on:
6974
container-registry-password:
7075
description: Container registry password
7176
required: true
72-
extra-vars:
77+
secret-vars:
7378
description: "Additional environment variables"
7479
required: false
7580

@@ -81,17 +86,18 @@ jobs:
8186
run:
8287
working-directory: ${{ inputs.working-directory }}
8388
steps:
84-
- name: Set additional variables
89+
- name: Set secret variables
90+
shell: bash
91+
env:
92+
SECRET_VARS: ${{ secrets.secret-vars }}
8593
run: |
86-
if [[ -z "${{ secrets.extra-vars }}" ]]; then
87-
echo "No extra-vars bundle provided - skipping."
88-
else
89-
echo "${{ secrets.extra-vars }}" | while IFS='=' read -r key val; do
94+
if [[ -n "$SECRET_VARS" ]]; then
95+
echo "$SECRET_VARS" | while IFS='=' read -r key val; do
9096
if [[ -n "$val" ]]; then
9197
echo "::add-mask::$val"
9298
fi
9399
done
94-
echo "${{ secrets.extra-vars }}" >> "$GITHUB_ENV"
100+
echo "$SECRET_VARS" >> "$GITHUB_ENV"
95101
fi
96102
- name: Clone repository
97103
uses: actions/checkout@v6
@@ -101,14 +107,23 @@ jobs:
101107
repository: devpro/github-workflow-parts
102108
ref: ${{ inputs.workflow-parts-version }}
103109
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
104114
- name: Login to container registry
105-
uses: docker/login-action@v3
115+
uses: docker/login-action@v4
106116
with:
107117
registry: ${{ inputs.container-registry }}
108118
username: ${{ secrets.container-registry-username }}
109119
password: ${{ secrets.container-registry-password }}
110120
- name: Build container image
111-
run: docker build . --file ${{ inputs.image-definition }} --tag ${{ env.IMAGE_REF }} ${{ inputs.extra-build-arguments }}
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 }}
112127
shell: bash
113128
- name: Generate SBOM with Syft
114129
uses: anchore/sbom-action@v0

0 commit comments

Comments
 (0)