Files
conjurer/.gitea/workflows/build.yaml
T
gitea c8aae10671
build / build (push) Successful in 43m17s
CI / compile (push) Successful in 1m24s
CI / unit (push) Successful in 47s
CI / integration (push) Failing after 1m38s
build-radio change
2026-07-28 12:56:14 +02:00

76 lines
3.3 KiB
YAML

name: build
on:
push:
branches: [main] # ← PODMIEŃ na swoją gałąź
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Login do rejestru
run: echo "${{ secrets.REGISTRY_TOKEN }}" | docker login gitea.czernobog.pl -u gitea --password-stdin
# Lekkie obrazy k3s-owe — budowane zawsze
- name: Build k3s images (librarian, bot)
run: |
TAG=${GITHUB_SHA::8}
docker build -f docker/Dockerfile.librarian -t gitea.czernobog.pl/gitea/conjurer-librarian:$TAG .
docker push gitea.czernobog.pl/gitea/conjurer-librarian:$TAG
docker build -f docker/Dockerfile.bot -t gitea.czernobog.pl/gitea/conjurer-bot:$TAG .
docker push gitea.czernobog.pl/gitea/conjurer-bot:$TAG
# Docker-owe: musician i share lekkie, radio CIĘŻKIE (opam+OCaml+liquidsoap)
- name: Build docker-stack images (musician, share)
run: |
TAG=${GITHUB_SHA::8}
docker build -f docker/Dockerfile.musician -t gitea.czernobog.pl/gitea/conjurer-musician:$TAG .
docker push gitea.czernobog.pl/gitea/conjurer-musician:$TAG
docker build -f docker/Dockerfile.share -t gitea.czernobog.pl/gitea/conjurer-share:$TAG .
docker push gitea.czernobog.pl/gitea/conjurer-share:$TAG
# RADIO: budowane TYLKO gdy zmieniło się coś istotnego (oszczędza ~15 min na push)
- name: Czy radio wymaga rebuildu?
id: radio_changed
env:
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
run: |
NEED=no
# Warunek 1: zmiany w plikach radia
if git rev-parse HEAD~1 >/dev/null 2>&1; then BASE=HEAD~1; else BASE=$(git hash-object -t tree /dev/null); fi
if git diff --name-only "$BASE" HEAD | grep -qE "docker/Dockerfile.radio|docker/entrypoint.radio.sh|docker/icecast.xml.tpl|docker/pulse-system.pa|conjurer_musician/radio_conjurer.liq|conjurer_betoniarka/"; then
NEED=yes
echo "radio: wykryto zmiany w plikach → build"
fi
# Warunek 2: obrazu nie ma w rejestrze (inicjalizacja)
if [ "$NEED" = "no" ]; then
TAGS=$(curl -s -u "gitea:${REGISTRY_TOKEN}" \
"https://gitea.czernobog.pl/v2/gitea/conjurer-radio/tags/list" 2>/dev/null || true)
# brak tagów w ogóle = obraz nie istnieje → zbuduj
if ! echo "$TAGS" | grep -q '"tags"[[:space:]]*:[[:space:]]*\['; then
NEED=yes
echo "radio: brak obrazu w rejestrze → build inicjalizujący"
elif echo "$TAGS" | grep -qE '"tags"[[:space:]]*:[[:space:]]*\[[[:space:]]*\]|"tags"[[:space:]]*:[[:space:]]*null'; then
NEED=yes
echo "radio: obraz istnieje ale bez tagów → build"
fi
fi
echo "build=$NEED" >> $GITHUB_OUTPUT
[ "$NEED" = "no" ] && echo "radio bez zmian i obraz istnieje — pomijam ciężki build" || true
- name: Build radio
if: steps.radio_changed.outputs.build == 'yes'
run: |
TAG=${GITHUB_SHA::8}
docker build -f docker/Dockerfile.radio -t gitea.czernobog.pl/gitea/conjurer-radio:$TAG .
docker push gitea.czernobog.pl/gitea/conjurer-radio:$TAG
- name: Podsumowanie
run: echo "Zbudowano tag ${GITHUB_SHA::8}"