Add builder workflow

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2025-09-14 16:58:28 +01:00
parent f3162e1620
commit ccb0e8df93

View File

@@ -0,0 +1,64 @@
name: Build & Push Builder Image
on:
workflow_call:
inputs:
registry:
required: true
type: string
username:
required: true
type: string
secrets:
password:
required: true
outputs:
tag:
description: "The built image reference"
value: ${{ jobs.builder.outputs.tag }}
jobs:
builder:
runs-on: nix
outputs:
tag: ${{ steps.build.outputs.tag }}
env:
IMAGE_BASE: ${{ inputs.registry }}/${{ github.repository_owner }}/${{ github.event.repository.name }}
TAG_COMMIT: builder-${{ github.sha }}
TAG_MAIN: builder
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Log In to Registry
run: buildah login --username "${{ inputs.username }}" --password "${{ secrets.password }}" "${{ inputs.registry }}"
- name: Pull Builder Cache
run: buildah pull ${{ env.IMAGE_BASE }}:${{ env.TAG_MAIN }} || true
- name: Build Builder Image
id: build
run: |
TAG_ARGS="--tag ${{ env.IMAGE_BASE }}:${{ env.TAG_COMMIT }}"
if [[ "${{ github.ref_name }}" == "main" ]]; then
TAG_ARGS="$TAG_ARGS --tag ${{ env.IMAGE_BASE }}:${{ env.TAG_MAIN }}"
fi
buildah build --layers -f .gitea/Containerfile $TAG_ARGS .
echo "tag=${{ env.IMAGE_BASE }}:${{ env.TAG_COMMIT }}" >> $GITEA_OUTPUT
- name: Push Builder Image
run: |
buildah push ${{ env.IMAGE_BASE }}:${{ env.TAG_COMMIT }}
if [[ "${{ github.ref_name }}" == "main" ]]; then
buildah push ${{ env.IMAGE_BASE }}:${{ env.TAG_MAIN }}
fi