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