name: images-build-and-push on: push: branches: [ "main" ] workflow_dispatch: {} env: REGISTRY: ${{ secrets.REGISTRY }} REGISTRY_USER: ${{ secrets.REGISTRY_USER }} REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} jobs: build: runs-on: ubuntu-latest strategy: fail-fast: false matrix: include: - name: debian context: . dockerfile: debian.dockerfile image: | xdu/debian:latest xdu/debian:trixie - name: debian-12 context: . dockerfile: debian-12.dockerfile image: | xdu/debian:bookworm - name: ubuntu context: . dockerfile: ubuntu.dockerfile image: | xdu/ubuntu:latest xdu/ubuntu:25.10 - name: ffmpeg context: . dockerfile: ffmpeg-debian.dockerfile image: | xdu/ffmpeg:debian xdu/ffmpeg:latest steps: - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 1 - name: Login to registry uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ env.REGISTRY_USER }} password: ${{ env.REGISTRY_PASSWORD }} - name: Prepare tags & cache repo id: meta shell: bash run: | FULL_TAGS="" FIRST_REPO="" while IFS= read -r line; do [ -z "$line" ] && continue TAG="${{ env.REGISTRY }}/$line" FULL_TAGS="${FULL_TAGS}${TAG}"$'\n' if [ -z "$FIRST_REPO" ]; then FIRST_REPO="${{ env.REGISTRY }}/$(echo "$line" | cut -d: -f1)" fi done <<< "${{ matrix.image }}" { echo "tags<<__TAGS__" printf "%s" "$FULL_TAGS" echo "__TAGS__" echo "cache_repo=$FIRST_REPO" } >> "$GITHUB_OUTPUT" - name: Build & Push (always) uses: docker/build-push-action@v5 with: context: ${{ matrix.context }} file: ${{ matrix.dockerfile }} push: true tags: ${{ steps.meta.outputs.tags }} cache-from: type=registry,ref=${{ steps.meta.outputs.cache_repo }}:buildcache${{ matrix.name }} cache-to: type=registry,ref=${{ steps.meta.outputs.cache_repo }}:buildcache${{ matrix.name }},mode=max