workflow matrix

This commit is contained in:
Domingo Dirutigliano
2025-08-04 11:47:14 +02:00
parent d868e046de
commit 7e28fdab8d

View File

@@ -10,8 +10,17 @@ env:
IMAGE_NAME: ${{ github.repository }} IMAGE_NAME: ${{ github.repository }}
jobs: jobs:
build-amd64: docker_build:
runs-on: ubuntu-latest runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
arch: amd64
run_tests: true
- os: ubuntu-24.04-arm
arch: arm64
run_tests: false
permissions: permissions:
contents: read contents: read
packages: write packages: write
@@ -20,10 +29,12 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Build and run firegex - name: Build and run firegex (amd64 only)
if: matrix.run_tests
run: python3 start.py start -P testpassword run: python3 start.py start -P testpassword
- name: Run tests - name: Run tests (amd64 only)
if: matrix.run_tests
run: sudo apt-get install -y iperf3 && cd tests && ./run_tests.sh run: sudo apt-get install -y iperf3 && cd tests && ./run_tests.sh
- name: Set up Docker Buildx - name: Set up Docker Buildx
@@ -53,76 +64,21 @@ jobs:
sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.TAG_NAME }}/g" fgex-lib/setup.py; sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.TAG_NAME }}/g" fgex-lib/setup.py;
sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.TAG_NAME }}/g" fgex-lib/firegex/__init__.py; sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.TAG_NAME }}/g" fgex-lib/firegex/__init__.py;
- name: Build and push AMD64 Docker image - name: Build and push Docker image
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
with: with:
context: . context: .
builder: ${{ steps.buildx.outputs.name }} builder: ${{ steps.buildx.outputs.name }}
platforms: linux/amd64 platforms: linux/${{ matrix.arch }}
push: true push: true
tags: ${{ steps.meta.outputs.tags }}-amd64 tags: ${{ steps.meta.outputs.tags }}-${{ matrix.arch }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=amd64 cache-from: type=gha,scope=${{ matrix.arch }}
cache-to: type=gha,mode=max,scope=amd64 cache-to: type=gha,mode=max,scope=${{ matrix.arch }}
build-arm64: docker_manifest:
runs-on: ubuntu-latest-arm64 needs: docker_build
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Build and run firegex
run: python3 start.py start -P testpassword
- name: Run tests
run: sudo apt-get install -y iperf3 && cd tests && ./run_tests.sh
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Extract tag name
id: tag
run: echo TAG_NAME=$(echo $GITHUB_REF | cut -d / -f 3) >> $GITHUB_OUTPUT
- name: Update version in setup.py
run: >-
sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.TAG_NAME }}/g" backend/utils/__init__.py;
sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.TAG_NAME }}/g" fgex-lib/setup.py;
sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.TAG_NAME }}/g" fgex-lib/firegex/__init__.py;
- name: Build and push ARM64 Docker image
uses: docker/build-push-action@v5
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
platforms: linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}-arm64
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=arm64
cache-to: type=gha,mode=max,scope=arm64
create-manifest:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [build-amd64, build-arm64]
permissions: permissions:
contents: read contents: read
packages: write packages: write
@@ -144,14 +100,14 @@ jobs:
- name: Create and push multi-platform manifest - name: Create and push multi-platform manifest
run: | run: |
# Create manifest list # Create manifest list
docker buildx imagetools create \ docker manifest create ${{ steps.meta.outputs.tags }} \
--tag ${{ steps.meta.outputs.tags }} \
${{ steps.meta.outputs.tags }}-amd64 \ ${{ steps.meta.outputs.tags }}-amd64 \
${{ steps.meta.outputs.tags }}-arm64 ${{ steps.meta.outputs.tags }}-arm64
docker manifest push ${{ steps.meta.outputs.tags }}
create-rootfs-assets: create-rootfs-assets:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [create-manifest] needs: [docker_manifest]
permissions: permissions:
contents: write contents: write
packages: read packages: read