name: "images4docker: Build" on: workflow_dispatch: workflow_call: permissions: contents: read packages: write jobs: prepare: runs-on: ubuntu-latest outputs: matrix: ${{ steps.make.outputs.matrix }} count: ${{ steps.make.outputs.count }} steps: - uses: actions/checkout@v6 - id: make run: | set -euo pipefail entries=() for f in images4docker/dockerfiles/*.Dockerfile; do name="$(basename "$f" .Dockerfile)" entries+=("$name|$f") done json='{"include":[' first=true for entry in "${entries[@]}"; do IFS='|' read -r name dockerfile <<< "$entry" $first || json+=',' first=false json+="{\"name\":\"$name\",\"dockerfile\":\"$dockerfile\"}" done json+=']}' echo "matrix=$json" >> "$GITHUB_OUTPUT" echo "count=${#entries[@]}" >> "$GITHUB_OUTPUT" build: needs: prepare if: needs.prepare.outputs.count != '0' runs-on: ubuntu-latest strategy: fail-fast: false max-parallel: 6 matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }} steps: - uses: actions/checkout@v6 - name: Login to GHCR uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Compute image tags id: tagmeta run: | set -euo pipefail short_sha="${GITHUB_SHA::12}" ts="$(date -u +%Y%m%d-%H%M%S)" echo "sha_tag=sha-${short_sha}" >> "$GITHUB_OUTPUT" echo "immutable_tag=${ts}-r${GITHUB_RUN_ID}-a${GITHUB_RUN_ATTEMPT}-${short_sha}" >> "$GITHUB_OUTPUT" - name: Build and push image uses: docker/build-push-action@v6 with: context: images4docker file: ${{ matrix.dockerfile }} push: true provenance: false tags: | ghcr.io/project-tick/project-tick/${{ matrix.name }}:latest ghcr.io/project-tick/project-tick/${{ matrix.name }}:${{ steps.tagmeta.outputs.sha_tag }} ghcr.io/project-tick/project-tick/${{ matrix.name }}:${{ steps.tagmeta.outputs.immutable_tag }}