Skip to content

Build

Build #18

Workflow file for this run

---
name: Build
on:
push:
branches:
- main
paths:
- '*/Containerfile'
- '*/**'
- '!.github/**'
workflow_dispatch:
inputs:
image:
description: 'Image to build (leave empty for all)'
required: false
permissions:
contents: read
packages: write
jobs:
detect:
runs-on: arc
outputs:
images: ${{ steps.find.outputs.images }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Find changed images
id: find
run: |
if [ -n "${{ inputs.image }}" ]; then
# Specific image requested
echo "images=[\"${{ inputs.image }}\"]" >> "$GITHUB_OUTPUT"
elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
# Manual trigger without specific image: build all
images=$(make list-images-json)
echo "images=$images" >> "$GITHUB_OUTPUT"
else
# Push event: only build changed images
images=$(make changed-images)
echo "images=$images" >> "$GITHUB_OUTPUT"
fi
build:
needs: detect
if: needs.detect.outputs.images != '[]'
runs-on: arc-dind
strategy:
matrix:
image: ${{ fromJson(needs.detect.outputs.images) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install buildah and hadolint
run: |
sudo apt-get update
sudo apt-get install -y buildah
mkdir -p $HOME/.local/bin
curl -sSL -o $HOME/.local/bin/hadolint \
https://github.com/hadolint/hadolint/releases/download/v2.12.0/hadolint-Linux-x86_64
chmod +x $HOME/.local/bin/hadolint
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Run pre-commit
uses: pre-commit/action@v3.0.1
- name: Build image
uses: redhat-actions/buildah-build@v2
with:
context: ${{ matrix.image }}
containerfiles: ${{ matrix.image }}/Containerfile
image: ${{ matrix.image }}
tags: latest ${{ github.sha }}
extra-args: --squash
- name: Push to registry
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ matrix.image }}
tags: latest ${{ github.sha }}
registry: ghcr.io/makeitworkcloud
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}