2026-11-17 15:04:00 -05:00
|
|
|
# Build changed OSINT images and publish them to the Forgejo container
|
|
|
|
|
# registry. Deployment is NOT done here: the cluster (homek8s, namespace
|
|
|
|
|
# `osint`) runs amd64 images pinned by tag in apps/base/osint/*.yaml, so the
|
|
|
|
|
# final step prints the tag to pin and a human opens that manifest PR.
|
2026-08-28 03:55:00 +00:00
|
|
|
#
|
2026-08-29 19:32:00 -04:00
|
|
|
# Unchanged images are skipped. Dockerfile.pg / osint-dashboard-pg is NOT
|
2026-11-17 15:04:00 -05:00
|
|
|
# rebuilt on a normal merge — Postgres stays up. Rebuild it only when
|
|
|
|
|
# Dockerfile.pg changes, or via workflow_dispatch rebuild_pg.
|
|
|
|
|
#
|
|
|
|
|
# Registry endpoints
|
|
|
|
|
# CI push host: forgejo.forgejo.svc.cluster.local:3000 — plain HTTP
|
|
|
|
|
# ClusterIP, whitelisted by --insecure-registry on the amd64
|
|
|
|
|
# runner's dind daemon. 127.0.0.1:3000 stopped working when
|
|
|
|
|
# Forgejo moved into k8s: inside an in-cluster job pod, loopback
|
|
|
|
|
# is the pod itself, so login died with "connection refused".
|
|
|
|
|
# Public pull: forgejo.siriusdevops.com (HTTPS via Cloudflare; kubelet pulls
|
|
|
|
|
# from here). Do NOT push here — Cloudflare 413s layers ≳100MB.
|
2026-08-29 19:32:00 -04:00
|
|
|
#
|
2026-08-28 00:17:52 -04:00
|
|
|
# Images (public names):
|
2026-11-17 15:04:00 -05:00
|
|
|
# forgejo.siriusdevops.com/sirius/osint-dashboard:amd64-<sha12>
|
|
|
|
|
# forgejo.siriusdevops.com/sirius/osint-dashboard-pg:amd64-<sha12>
|
|
|
|
|
# forgejo.siriusdevops.com/sirius/osint-news-scraper:amd64-<sha12>
|
|
|
|
|
# forgejo.siriusdevops.com/sirius/osint-news-summarizer:amd64-<sha12>
|
2026-08-28 03:55:00 +00:00
|
|
|
#
|
2026-08-28 00:17:52 -04:00
|
|
|
# Optional repo variable FORGEJO_REGISTRY overrides the *public* pull host.
|
2026-08-28 03:55:00 +00:00
|
|
|
|
2026-07-07 17:50:51 -04:00
|
|
|
name: build-and-deploy
|
2026-08-28 03:55:00 +00:00
|
|
|
|
2026-07-07 17:50:51 -04:00
|
|
|
on:
|
|
|
|
|
push:
|
|
|
|
|
branches: [main, master]
|
2026-08-28 03:55:00 +00:00
|
|
|
workflow_dispatch:
|
2026-08-29 19:32:00 -04:00
|
|
|
inputs:
|
|
|
|
|
rebuild_pg:
|
|
|
|
|
description: Rebuild Timescale+PostGIS (Dockerfile.pg)
|
|
|
|
|
type: boolean
|
|
|
|
|
default: false
|
|
|
|
|
rebuild_all:
|
|
|
|
|
description: Rebuild every app image (ignore path filter)
|
|
|
|
|
type: boolean
|
|
|
|
|
default: false
|
2026-08-28 03:55:00 +00:00
|
|
|
|
|
|
|
|
env:
|
2026-08-28 00:17:52 -04:00
|
|
|
PUBLIC_REGISTRY: ${{ vars.FORGEJO_REGISTRY || 'forgejo.siriusdevops.com' }}
|
2026-11-17 15:04:00 -05:00
|
|
|
PUSH_REGISTRY: forgejo.forgejo.svc.cluster.local:3000
|
2026-08-28 03:55:00 +00:00
|
|
|
OWNER: sirius
|
|
|
|
|
|
2026-07-07 17:50:51 -04:00
|
|
|
jobs:
|
2026-11-17 15:04:00 -05:00
|
|
|
build-push:
|
|
|
|
|
# `amd64` only exists on siriussec-amd64, which is also the node the
|
|
|
|
|
# workloads run on — so the images are built on the architecture they are
|
|
|
|
|
# pulled to. `runs-on: docker` matched the Pi's arm64 runner, which
|
|
|
|
|
# produced images the amd64 cluster could never run.
|
|
|
|
|
# No job-level `permissions:` block: Forgejo ignores it (it emits a
|
|
|
|
|
# pre-execution warning) and the push authenticates with the FORGEJO_TOKEN
|
|
|
|
|
# user PAT instead, because the package registry rejects the Actions token.
|
|
|
|
|
runs-on: amd64
|
2026-07-07 17:50:51 -04:00
|
|
|
steps:
|
|
|
|
|
- name: Checkout
|
|
|
|
|
uses: https://code.forgejo.org/actions/checkout@v4
|
2026-08-29 19:32:00 -04:00
|
|
|
with:
|
|
|
|
|
fetch-depth: 50
|
|
|
|
|
|
|
|
|
|
- name: Plan image builds
|
|
|
|
|
id: plan
|
|
|
|
|
run: |
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
APP=0
|
|
|
|
|
SCRAPER=0
|
|
|
|
|
SUM=0
|
|
|
|
|
PG=0
|
|
|
|
|
|
|
|
|
|
mark() {
|
|
|
|
|
case "$1" in
|
|
|
|
|
Dockerfile.pg)
|
|
|
|
|
PG=1 ;;
|
|
|
|
|
Dockerfile|app/*|alembic/*|alembic.ini)
|
|
|
|
|
APP=1 ;;
|
|
|
|
|
news/scraper/*)
|
|
|
|
|
SCRAPER=1 ;;
|
|
|
|
|
news/summerizer/*)
|
|
|
|
|
SUM=1 ;;
|
|
|
|
|
esac
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
|
|
|
|
APP=1; SCRAPER=1; SUM=1
|
|
|
|
|
if [ "${{ github.event.inputs.rebuild_all }}" = "true" ]; then
|
|
|
|
|
APP=1; SCRAPER=1; SUM=1; PG=1
|
|
|
|
|
fi
|
|
|
|
|
if [ "${{ github.event.inputs.rebuild_pg }}" = "true" ]; then
|
|
|
|
|
PG=1
|
|
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
BEFORE="${{ github.event.before }}"
|
|
|
|
|
SHA="${GITHUB_SHA}"
|
|
|
|
|
ZEROS="0000000000000000000000000000000000000000"
|
|
|
|
|
if [ -z "$BEFORE" ] || [ "$BEFORE" = "$ZEROS" ]; then
|
|
|
|
|
echo "No previous SHA — build app images, skip pg"
|
|
|
|
|
APP=1; SCRAPER=1; SUM=1
|
|
|
|
|
elif ! git cat-file -e "${BEFORE}^{commit}" 2>/dev/null; then
|
|
|
|
|
echo "Previous SHA $BEFORE not in history — build app images, skip pg"
|
|
|
|
|
APP=1; SCRAPER=1; SUM=1
|
|
|
|
|
else
|
|
|
|
|
while IFS= read -r f; do
|
|
|
|
|
[ -z "$f" ] && continue
|
|
|
|
|
mark "$f"
|
|
|
|
|
done < <(git diff --name-only "$BEFORE" "$SHA")
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
echo "app=$APP"
|
|
|
|
|
echo "scraper=$SCRAPER"
|
|
|
|
|
echo "summarizer=$SUM"
|
|
|
|
|
echo "pg=$PG"
|
|
|
|
|
} >> "$GITHUB_OUTPUT"
|
2026-11-17 15:04:00 -05:00
|
|
|
echo "plan app=$APP scraper=$SCRAPER summarizer=$SUM pg=$PG"
|
2026-08-28 03:55:00 +00:00
|
|
|
|
|
|
|
|
- name: Image refs
|
|
|
|
|
id: img
|
|
|
|
|
run: |
|
|
|
|
|
set -euo pipefail
|
2026-08-28 00:17:52 -04:00
|
|
|
PUSH="${PUSH_REGISTRY}"
|
|
|
|
|
PUB="${PUBLIC_REGISTRY}"
|
2026-08-28 03:55:00 +00:00
|
|
|
OWN="${OWNER}"
|
|
|
|
|
SHA="${GITHUB_SHA::12}"
|
2026-11-17 15:04:00 -05:00
|
|
|
TAG="amd64-${SHA}"
|
2026-08-28 03:55:00 +00:00
|
|
|
{
|
2026-08-28 00:17:52 -04:00
|
|
|
echo "reg=$PUSH"
|
|
|
|
|
echo "pub=$PUB"
|
2026-11-17 15:04:00 -05:00
|
|
|
echo "tag=$TAG"
|
2026-08-28 00:17:52 -04:00
|
|
|
echo "app=$PUSH/$OWN/osint-dashboard"
|
|
|
|
|
echo "pg=$PUSH/$OWN/osint-dashboard-pg"
|
|
|
|
|
echo "scraper=$PUSH/$OWN/osint-news-scraper"
|
|
|
|
|
echo "summarizer=$PUSH/$OWN/osint-news-summarizer"
|
2026-08-28 03:55:00 +00:00
|
|
|
} >> "$GITHUB_OUTPUT"
|
2026-08-28 00:17:52 -04:00
|
|
|
echo "Push registry: $PUSH"
|
|
|
|
|
echo "Public pull: $PUB"
|
2026-11-17 15:04:00 -05:00
|
|
|
echo "Image tag: $TAG"
|
2026-08-28 03:55:00 +00:00
|
|
|
|
|
|
|
|
- name: Login to Forgejo registry
|
2026-08-29 19:32:00 -04:00
|
|
|
if: steps.plan.outputs.app == '1' || steps.plan.outputs.scraper == '1' || steps.plan.outputs.summarizer == '1' || steps.plan.outputs.pg == '1'
|
2026-08-28 03:55:00 +00:00
|
|
|
run: |
|
|
|
|
|
set -euo pipefail
|
2026-08-28 00:15:19 -04:00
|
|
|
# GITHUB_TOKEN login "succeeds" but blob uploads 401 (Forgejo packages
|
2026-11-17 15:10:13 -05:00
|
|
|
# reject the Actions token). Use a user PAT.
|
|
|
|
|
# The PAT must carry the `write:package` scope: Forgejo mints a push
|
|
|
|
|
# token even without it and then rejects every blob upload with
|
|
|
|
|
# `unauthorized: reqPackageAccess` (routers/api/packages/api.go
|
|
|
|
|
# reqPackageAccess -> AccessTokenScopeWritePackage).
|
|
|
|
|
# Name is REGISTRY_TOKEN, not FORGEJO_TOKEN: Forgejo reserves the
|
|
|
|
|
# FORGEJO_/GITHUB_ prefixes and refuses to create or update them via
|
|
|
|
|
# the API.
|
|
|
|
|
if [ -z "${{ secrets.REGISTRY_TOKEN }}" ]; then
|
|
|
|
|
echo "Missing repo secret REGISTRY_TOKEN (user PAT with write:package, not GITHUB_TOKEN)"
|
2026-08-28 00:15:19 -04:00
|
|
|
exit 1
|
|
|
|
|
fi
|
2026-11-17 15:10:13 -05:00
|
|
|
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login "${{ steps.img.outputs.reg }}" \
|
2026-08-28 00:15:19 -04:00
|
|
|
-u sirius --password-stdin
|
2026-08-28 03:55:00 +00:00
|
|
|
|
|
|
|
|
- name: Build application image (api / ingester / cameras)
|
2026-08-29 19:32:00 -04:00
|
|
|
if: steps.plan.outputs.app == '1'
|
2026-08-28 03:55:00 +00:00
|
|
|
run: |
|
|
|
|
|
set -ex
|
2026-11-17 15:04:00 -05:00
|
|
|
IMG="${{ steps.img.outputs.app }}"
|
|
|
|
|
TAG="${{ steps.img.outputs.tag }}"
|
|
|
|
|
docker build -f Dockerfile -t "${IMG}:${TAG}" .
|
|
|
|
|
docker push "${IMG}:${TAG}"
|
2026-08-28 03:55:00 +00:00
|
|
|
|
|
|
|
|
- name: Build news-scraper image
|
2026-08-29 19:32:00 -04:00
|
|
|
if: steps.plan.outputs.scraper == '1'
|
2026-08-28 03:55:00 +00:00
|
|
|
run: |
|
|
|
|
|
set -ex
|
|
|
|
|
IMG="${{ steps.img.outputs.scraper }}"
|
2026-11-17 15:04:00 -05:00
|
|
|
TAG="${{ steps.img.outputs.tag }}"
|
|
|
|
|
docker build -f news/scraper/Dockerfile -t "${IMG}:${TAG}" news/scraper
|
|
|
|
|
docker push "${IMG}:${TAG}"
|
2026-08-28 03:55:00 +00:00
|
|
|
|
|
|
|
|
- name: Build news-summarizer image
|
2026-08-29 19:32:00 -04:00
|
|
|
if: steps.plan.outputs.summarizer == '1'
|
2026-08-28 03:55:00 +00:00
|
|
|
run: |
|
|
|
|
|
set -ex
|
|
|
|
|
IMG="${{ steps.img.outputs.summarizer }}"
|
2026-11-17 15:04:00 -05:00
|
|
|
TAG="${{ steps.img.outputs.tag }}"
|
|
|
|
|
docker build -f news/summerizer/Dockerfile -t "${IMG}:${TAG}" news/summerizer
|
|
|
|
|
docker push "${IMG}:${TAG}"
|
2026-08-28 03:55:00 +00:00
|
|
|
|
|
|
|
|
- name: Build / refresh Timescale+PostGIS image
|
2026-08-29 19:32:00 -04:00
|
|
|
if: steps.plan.outputs.pg == '1'
|
2026-08-28 03:55:00 +00:00
|
|
|
run: |
|
|
|
|
|
set -ex
|
2026-11-17 15:04:00 -05:00
|
|
|
IMG="${{ steps.img.outputs.pg }}"
|
|
|
|
|
TAG="${{ steps.img.outputs.tag }}"
|
|
|
|
|
docker build -f Dockerfile.pg -t "${IMG}:${TAG}" .
|
|
|
|
|
docker push "${IMG}:${TAG}"
|
2026-07-09 19:35:29 -04:00
|
|
|
|
2026-08-28 03:55:00 +00:00
|
|
|
- name: Summary
|
|
|
|
|
if: always()
|
|
|
|
|
run: |
|
2026-11-17 15:04:00 -05:00
|
|
|
TAG="${{ steps.img.outputs.tag }}"
|
|
|
|
|
PUB="${{ steps.img.outputs.pub }}"
|
2026-08-28 03:55:00 +00:00
|
|
|
{
|
2026-08-29 19:32:00 -04:00
|
|
|
echo "## Image plan"
|
|
|
|
|
echo "- app: \`${{ steps.plan.outputs.app }}\`"
|
|
|
|
|
echo "- news-scraper: \`${{ steps.plan.outputs.scraper }}\`"
|
|
|
|
|
echo "- news-summarizer: \`${{ steps.plan.outputs.summarizer }}\`"
|
|
|
|
|
echo "- pg (Timescale): \`${{ steps.plan.outputs.pg }}\`"
|
|
|
|
|
echo
|
2026-11-17 15:04:00 -05:00
|
|
|
if [ -n "$TAG" ]; then
|
|
|
|
|
echo "## Pin in homek8s (apps/base/osint)"
|
|
|
|
|
echo "Pushed tag: \`${TAG}\`. Set the workload images in"
|
|
|
|
|
echo "\`apps/base/osint/kustomization.yaml\` to:"
|
|
|
|
|
echo
|
|
|
|
|
echo '```yaml'
|
|
|
|
|
echo "images:"
|
|
|
|
|
echo " - name: ${PUB}/${OWNER}/osint-dashboard"
|
|
|
|
|
echo " newTag: ${TAG}"
|
|
|
|
|
echo " - name: ${PUB}/${OWNER}/osint-news-scraper"
|
|
|
|
|
echo " newTag: ${TAG}"
|
|
|
|
|
echo " - name: ${PUB}/${OWNER}/osint-news-summarizer"
|
|
|
|
|
echo " newTag: ${TAG}"
|
|
|
|
|
echo '```'
|
|
|
|
|
else
|
|
|
|
|
echo "_No tag computed — the earlier steps failed before Image refs._"
|
|
|
|
|
fi
|
|
|
|
|
echo
|
|
|
|
|
echo "Postgres is rebuilt only when \`Dockerfile.pg\` changes (or workflow_dispatch rebuild_pg)."
|
2026-08-28 03:55:00 +00:00
|
|
|
} >> "$GITHUB_STEP_SUMMARY"
|