fix: make docker reusable workflow more reusable (#11)

This commit is contained in:
Slava 2025-04-06 16:21:23 +03:00 committed by GitHub
parent b23d031ead
commit 401008d286
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -93,7 +93,12 @@ jobs:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
build_id: ${{ steps.build_id.outputs.build_id }}
steps:
- name: Generate unique build id
id: build_id
run: echo "build_id=$(openssl rand -hex 5)" >> $GITHUB_OUTPUT
- name: Compute matrix
id: matrix
uses: fabiocaccamo/create-matrix-action@v5
@ -104,16 +109,16 @@ jobs:
# Build platform specific image
build:
name: Build ${{ matrix.os }}/${{ matrix.arch }}
runs-on: ${{ matrix.builder }}
needs: compute
strategy:
fail-fast: true
matrix:
include: ${{ fromJson(needs.compute.outputs.matrix) }}
name: Build ${{ matrix.os }}/${{ matrix.arch }}
runs-on: ${{ matrix.builder }}
env:
PLATFORM: ${{ format('{0}/{1}', 'linux', matrix.arch) }}
steps:
- name: Checkout
uses: actions/checkout@v4
@ -175,7 +180,7 @@ jobs:
- name: Docker - Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ matrix.arch }}
name: digests-${{ needs.compute.outputs.build_id }}-${{ matrix.arch }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
@ -185,7 +190,7 @@ jobs:
publish:
name: Publish multi-platform image
runs-on: ubuntu-latest
needs: build
needs: [build, compute]
steps:
- name: Docker - Variables
run: |
@ -214,7 +219,7 @@ jobs:
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
pattern: digests-${{ needs.compute.outputs.build_id }}-*
merge-multiple: true
- name: Docker - Set up Buildx