Skip to content

buildah

buildah #23

Workflow file for this run

---
name: Build
on:
push:
branches:
- main
paths:
- '*/**'
- '!.github/**'
workflow_dispatch:
inputs:
image:
description: 'Image to build (leave empty for all)'
required: false
permissions:
contents: read
packages: write
jobs:
detect:
runs-on: ubuntu-latest
outputs:
images: ${{ steps.find.outputs.images }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Find changed images
id: find
env:
INPUT_IMAGE: ${{ inputs.image }}
run: |
if [ -n "$INPUT_IMAGE" ]; then
# Specific image requested
echo "images=[\"$INPUT_IMAGE\"]" >> "$GITHUB_OUTPUT"
elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
# Manual trigger without specific image: build all
echo "images=$(make list-images-json)" >> "$GITHUB_OUTPUT"
else
# Push event: only build changed images
echo "images=$(make changed-images)" >> "$GITHUB_OUTPUT"
fi
build:
needs: detect
if: needs.detect.outputs.images != '[]'
runs-on: ubuntu-latest
strategy:
matrix:
image: ${{ fromJson(needs.detect.outputs.images) }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install buildah, podman, and hadolint
run: |
sudo apt-get update
sudo apt-get install -y buildah podman
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 }}