Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 27 additions & 20 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ on:
workflow_dispatch:
inputs:
branch:
description: "Branch to build (e.g. my-feature-branch)"
description: "Branch to build (defaults to selected branch)"
type: string
required: true
required: false
default: ""
containers:
description: "Comma-separated container names to build, or 'all' for all containers"
type: string
Expand All @@ -26,27 +27,33 @@ permissions:
id-token: write

jobs:
detect-changes:
setup:
runs-on: ubuntu-latest
if: inputs.branch != 'main'
outputs:
branch: ${{ steps.resolve.outputs.branch }}
containers: ${{ steps.detect.outputs.containers }}
downstream_containers: ${{ steps.detect.outputs.downstream_containers }}
image_tag: ${{ steps.detect.outputs.image_tag }}
steps:
- name: Resolve branch
id: resolve
run: |
BRANCH="${{ inputs.branch || github.ref_name }}"
echo "branch=$BRANCH" >> $GITHUB_OUTPUT

- name: Checkout repository
uses: actions/checkout@v6
with:
ref: ${{ inputs.branch }}
ref: ${{ steps.resolve.outputs.branch }}

- name: Detect containers to build
- name: Resolve containers to build
id: detect
run: |
# Compute image tag from branch name unless an explicit tag was provided
if [[ -n "${{ inputs.tag }}" ]]; then
IMAGE_TAG="${{ inputs.tag }}"
else
IMAGE_TAG="dev-$(echo "${{ inputs.branch }}" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9._-]/-/g')"
IMAGE_TAG="dev-$(echo "${{ steps.resolve.outputs.branch }}" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9._-]/-/g')"
fi
echo "image_tag=$IMAGE_TAG" >> $GITHUB_OUTPUT

Expand Down Expand Up @@ -125,22 +132,22 @@ jobs:
fi

build:
needs: [ detect-changes ]
if: needs.detect-changes.outputs.containers != '[]'
needs: [ setup ]
if: needs.setup.outputs.containers != '[]'
runs-on: ubuntu-24.04-arm
env:
PYTHON_VERSION: "3.13"
TASKFILE_VERSION: "3.45.4"
strategy:
fail-fast: false
matrix:
container: ${{ fromJson(needs.detect-changes.outputs.containers) }}
container: ${{ fromJson(needs.setup.outputs.containers) }}

steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
ref: ${{ inputs.branch }}
ref: ${{ needs.setup.outputs.branch }}

- name: Set up Python
if: matrix.container == 'python-apps-base'
Expand Down Expand Up @@ -173,8 +180,8 @@ jobs:
uses: docker/metadata-action@v4
with:
tags: |
type=raw,value=${{ needs.detect-changes.outputs.image_tag }}
type=raw,value=${{ needs.detect-changes.outputs.image_tag }}-${{ github.run_number }}
type=raw,value=${{ needs.setup.outputs.image_tag }}
type=raw,value=${{ needs.setup.outputs.image_tag }}-${{ github.run_number }}
images: ghcr.io/${{ github.repository_owner }}/app-bricks/${{ matrix.container }}

- name: Build and push Docker image
Expand All @@ -192,22 +199,22 @@ jobs:
REGISTRY=${{ env.DEV_REGISTRY_PATH }}

build-downstream:
needs: [ detect-changes, build ]
if: needs.detect-changes.outputs.downstream_containers != '[]'
needs: [ setup, build ]
if: needs.setup.outputs.downstream_containers != '[]'
runs-on: ubuntu-24.04-arm
env:
PYTHON_VERSION: "3.13"
TASKFILE_VERSION: "3.45.4"
strategy:
fail-fast: false
matrix:
container: ${{ fromJson(needs.detect-changes.outputs.downstream_containers) }}
container: ${{ fromJson(needs.setup.outputs.downstream_containers) }}

steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
ref: ${{ inputs.branch }}
ref: ${{ needs.setup.outputs.branch }}

- name: Set up Python
if: matrix.container == 'python-apps-base'
Expand Down Expand Up @@ -240,8 +247,8 @@ jobs:
uses: docker/metadata-action@v4
with:
tags: |
type=raw,value=${{ needs.detect-changes.outputs.image_tag }}
type=raw,value=${{ needs.detect-changes.outputs.image_tag }}-${{ github.run_number }}
type=raw,value=${{ needs.setup.outputs.image_tag }}
type=raw,value=${{ needs.setup.outputs.image_tag }}-${{ github.run_number }}
images: ghcr.io/${{ github.repository_owner }}/app-bricks/${{ matrix.container }}

- name: Build and push Docker image
Expand All @@ -257,4 +264,4 @@ jobs:
provenance: false
build-args: |
REGISTRY=${{ env.DEV_REGISTRY_PATH }}
BASE_IMAGE_VERSION=${{ needs.detect-changes.outputs.image_tag }}
BASE_IMAGE_VERSION=${{ needs.setup.outputs.image_tag }}
Loading