Skip to content

Commit

Permalink
fix: refactor workflow to support multiple images
Browse files Browse the repository at this point in the history
  • Loading branch information
p5 committed Feb 1, 2025
1 parent efc11ec commit dba9bcb
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 18 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/build-dx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Build Bluefin LTS DX

on:
pull_request:
branches:
- main
schedule:
- cron: "0 1 * * TUE" # Every Tuesday at 1am UTC
merge_group:
push:
branches:
- main
paths-ignore:
- "**/README.md"
workflow_dispatch:

jobs:
build:
uses: ./.github/workflows/reusable-build-image.yml
with:
image-name: bluefin
image-desc: "Bluefin LTS, built on CentOS Stream with bootc"
flavor: dx
23 changes: 23 additions & 0 deletions .github/workflows/build-hwe.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Build Bluefin LTS HWE

on:
pull_request:
branches:
- main
schedule:
- cron: "0 1 * * TUE" # Every Tuesday at 1am UTC
merge_group:
push:
branches:
- main
paths-ignore:
- "**/README.md"
workflow_dispatch:

jobs:
build:
uses: ./.github/workflows/reusable-build-image.yml
with:
image-name: bluefin
image-desc: "Bluefin LTS, built on CentOS Stream with bootc"
flavor: hwe
22 changes: 22 additions & 0 deletions .github/workflows/build-regular.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Build Bluefin LTS

on:
pull_request:
branches:
- main
schedule:
- cron: "0 1 * * TUE" # Every Tuesday at 1am UTC
merge_group:
push:
branches:
- main
paths-ignore:
- "**/README.md"
workflow_dispatch:

jobs:
build:
uses: ./.github/workflows/reusable-build-image.yml
with:
image-name: bluefin
image-desc: "Bluefin LTS, built on CentOS Stream with bootc"
Original file line number Diff line number Diff line change
@@ -1,40 +1,66 @@
---
name: Build Image
on:
pull_request:
branches:
- main
schedule:
- cron: "0 1 * * TUE" # Every Tuesday at 1am UTC
merge_group:
push:
branches:
- main
paths-ignore:
- "**/README.md"
workflow_dispatch:
workflow_call:
inputs:
image-name:
description: "The name of the image to build"
required: true
type: string
image-desc:
description: "The description of the image to build"
required: true
type: string
flavor:
description: "The flavor of the image to build"
required: false
type: string
default: ""
platforms:
description: "The platforms to build the image for"
required: false
type: string
default: "amd64,arm64"

env:
IMAGE_NAME: "bluefin" # the name of the image produced by this build, matches repo names
IMAGE_DESC: "Bluefin LTS, built on CentOS Stream with bootc"
IMAGE_NAME: ${{ inputs.image-name }}
IMAGE_DESC: ${{ inputs.image-desc }}
IMAGE_REGISTRY: "ghcr.io/${{ github.repository_owner }}"
DEFAULT_TAG: "lts"
CENTOS_VERSION: "stream10"
PLATFORMS: ${{ inputs.platforms }}

concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true

jobs:
generate_matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Set matrix
id: set-matrix
run: |
# turn the comma separated string into a list
platforms=()
IFS=',' read -r -a platforms <<< "${{ inputs.platforms }}"
MATRIX="{\"include\":[]}"
for platform in "${platforms[@]}"; do
MATRIX=$(echo $MATRIX | jq ".include += [{\"platform\": \"$platform\"}]")
done
echo "matrix=$(echo $MATRIX | jq -c '.')" >> $GITHUB_OUTPUT
build_push:
name: Build and push image
runs-on: ${{ matrix.platform == 'amd64' && 'ubuntu-24.04' || 'ubuntu-24.04-arm' }}
timeout-minutes: 30
needs: generate_matrix
strategy:
fail-fast: false
matrix:
platform: ["amd64", "arm64"]
flavor: ["","hwe", "dx", "hwe-dx"]
matrix: ${{fromJson(needs.generate_matrix.outputs.matrix)}}
permissions:
contents: read
packages: write
Expand Down Expand Up @@ -71,7 +97,7 @@ jobs:
set -x
just=$(which just)
IMAGE_NAME=$IMAGE_NAME
FLAVOR=${{ matrix.flavor }}
FLAVOR=${{ inputs.flavor }}
ENABLE_DX=0
ENABLE_HWE=0
if [[ "$FLAVOR" =~ "dx" ]] ; then
Expand Down

0 comments on commit dba9bcb

Please sign in to comment.