55 lines
2.1 KiB
YAML
55 lines
2.1 KiB
YAML
name: '🐳 Builder Image'
|
|
|
|
# Reusable workflow: builds (and optionally pushes) the kpnpp-builder image.
|
|
# It is called by ci.yaml only when Dockerfile.builder or docs/requirements.txt
|
|
# change. It runs on the host runner (NOT inside the builder container) because
|
|
# it needs the Docker CLI/daemon.
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
push:
|
|
description: 'Push the built image to the registry'
|
|
type: boolean
|
|
default: true
|
|
workflow_dispatch:
|
|
inputs:
|
|
push:
|
|
description: 'Push the built image to the registry'
|
|
type: boolean
|
|
default: true
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: linux/amd64
|
|
steps:
|
|
# This job runs on the host (not in a container) so it can reach the
|
|
# host Docker daemon and reuse the cached registry credentials. The host
|
|
# has no Node, so the JS-based actions/checkout can't run here; do a
|
|
# minimal shallow fetch of this commit with plain git instead.
|
|
- name: Checkout repository
|
|
run: |
|
|
git init -q .
|
|
git remote add origin "${{ github.server_url }}/${{ github.repository }}.git"
|
|
git -c http.extraheader="AUTHORIZATION: basic $(printf '%s' '${{ github.actor }}:${{ github.token }}' | base64 -w0)" \
|
|
fetch --depth 1 origin "${{ github.sha }}"
|
|
git checkout -q FETCH_HEAD
|
|
|
|
# No docker login step: the host runner was authenticated to
|
|
# gitea.tourolle.paris with `docker login` during setup, so its cached
|
|
# credentials in ~/.docker/config.json cover the push below.
|
|
- name: Build builder image
|
|
# Context is the repo root because Dockerfile.builder COPYs
|
|
# docs/requirements.txt during the build.
|
|
run: |
|
|
docker build \
|
|
-f Dockerfile.builder \
|
|
-t gitea.tourolle.paris/dtourolle/kpnpp-builder:latest \
|
|
-t gitea.tourolle.paris/dtourolle/kpnpp-builder:${{ github.sha }} \
|
|
.
|
|
|
|
- name: Push builder image
|
|
if: ${{ inputs.push }}
|
|
run: |
|
|
docker push gitea.tourolle.paris/dtourolle/kpnpp-builder:latest
|
|
docker push gitea.tourolle.paris/dtourolle/kpnpp-builder:${{ github.sha }}
|