- Use separate image repos (ghcr.io/host-uk/core-dev, server-php) - Trigger on dev branch instead of main - Only build LinuxKit on tags - Add fail-fast: false to continue if one image fails Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
174 lines
4.8 KiB
YAML
174 lines
4.8 KiB
YAML
# Host UK Container Images
|
|
# Publishes to GHCR with separate image repos
|
|
#
|
|
# GHCR: ghcr.io/host-uk/core-dev
|
|
# GHCR: ghcr.io/host-uk/server-php
|
|
|
|
name: Build Images
|
|
|
|
on:
|
|
push:
|
|
branches: [dev]
|
|
tags: ['v*']
|
|
pull_request:
|
|
branches: [dev]
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
GHCR_REGISTRY: ghcr.io
|
|
|
|
jobs:
|
|
# ============================================================
|
|
# Build Docker Images
|
|
# ============================================================
|
|
docker:
|
|
name: Docker (${{ matrix.image }})
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
image:
|
|
- developer
|
|
- server-php
|
|
include:
|
|
- image: developer
|
|
ghcr_name: core-dev
|
|
- image: server-php
|
|
ghcr_name: server-php
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to GHCR
|
|
if: github.event_name != 'pull_request'
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.GHCR_REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Extract metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: |
|
|
${{ env.GHCR_REGISTRY }}/host-uk/${{ matrix.ghcr_name }}
|
|
tags: |
|
|
# dev branch -> dev tag
|
|
type=ref,event=branch
|
|
# PR number
|
|
type=ref,event=pr
|
|
# Semver tags (v1.0.0 -> 1.0.0, 1.0, 1, latest)
|
|
type=semver,pattern={{version}}
|
|
type=semver,pattern={{major}}.{{minor}}
|
|
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
|
|
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
|
|
flavor: |
|
|
latest=false
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: ./${{ matrix.image }}
|
|
platforms: linux/amd64,linux/arm64
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
|
|
# ============================================================
|
|
# Build LinuxKit Images (only on tags)
|
|
# ============================================================
|
|
linuxkit:
|
|
name: LinuxKit (${{ matrix.image }}-${{ matrix.arch }})
|
|
runs-on: ubuntu-latest
|
|
needs: docker
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
|
|
strategy:
|
|
matrix:
|
|
image: [developer, server-php]
|
|
arch: [amd64, arm64]
|
|
format: [qcow2-bios, iso-bios]
|
|
include:
|
|
- image: developer
|
|
output_name: core-dev
|
|
- image: server-php
|
|
output_name: server-php
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install LinuxKit
|
|
run: |
|
|
curl -fsSL "https://github.com/linuxkit/linuxkit/releases/download/v1.5.3/linuxkit-linux-amd64" -o linuxkit
|
|
chmod +x linuxkit
|
|
sudo mv linuxkit /usr/local/bin/
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v3
|
|
|
|
- name: Login to GHCR
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.GHCR_REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build LinuxKit Image
|
|
run: |
|
|
mkdir -p dist
|
|
linuxkit build \
|
|
--format ${{ matrix.format }} \
|
|
--name ./dist/${{ matrix.output_name }}-${{ matrix.arch }} \
|
|
./${{ matrix.image }}/linuxkit.yml
|
|
|
|
- name: Upload Artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ matrix.output_name }}-${{ matrix.arch }}-${{ matrix.format }}
|
|
path: ./dist/*
|
|
|
|
# ============================================================
|
|
# Release LinuxKit Images
|
|
# ============================================================
|
|
release-linuxkit:
|
|
name: Release LinuxKit Images
|
|
runs-on: ubuntu-latest
|
|
needs: linuxkit
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
permissions:
|
|
contents: write
|
|
|
|
steps:
|
|
- name: Download all artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: ./dist
|
|
merge-multiple: true
|
|
|
|
- name: Generate checksums
|
|
run: |
|
|
cd dist
|
|
sha256sum * > checksums.txt
|
|
|
|
- name: Upload to Release
|
|
uses: softprops/action-gh-release@v1
|
|
with:
|
|
files: |
|
|
dist/*
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|