demo-app/.forgejo/workflows/ci.yml
gitea_admin 682f2e4e84
Some checks are pending
/ build-and-deploy (push) Waiting to run
add .forgejo/workflows/ci.yml
2026-07-06 15:09:15 +00:00

45 lines
1.9 KiB
YAML

# Forgejo Actions CI — runs on push, executed by the in-cluster runner inside
# the ci-builder job container (docker CLI + buildx + git). Fully sovereign:
# no external actions (manual git over forgejo-http), builds via the in-pod
# DinD ($DOCKER_HOST), pushes to Forgejo's registry, bumps the manifest tag
# (commit marked [skip ci]) so Argo CD redeploys.
on:
push:
branches: [main]
jobs:
build-and-deploy:
runs-on: docker
env:
DOCKER_HOST: tcp://localhost:2375 # in-pod DinD (job shares pod netns)
REGISTRY: forgejo-http:3000
OWNER: gitea_admin
REPO: demo-app
steps:
- name: Checkout (manual — sovereign, no github.com)
env: { REG_PASS: "${{ secrets.REGISTRY_PASS }}" }
run: |
set -eu
git clone --depth 1 "http://${OWNER}:${REG_PASS}@${REGISTRY}/${OWNER}/${REPO}.git" src
cd src && git log -1 --oneline
- name: Build & push image
env: { REG_PASS: "${{ secrets.REGISTRY_PASS }}" }
run: |
set -eu
TAG="$(echo "${GITHUB_SHA}" | cut -c1-12)"
IMAGE="${REGISTRY}/${OWNER}/${REPO}:${TAG}"
echo "${REG_PASS}" | docker login "${REGISTRY}" -u "${OWNER}" --password-stdin
docker build -t "${IMAGE}" ./src
docker push "${IMAGE}"
echo "TAG=${TAG}" >> "${GITHUB_ENV}"
- name: Bump manifest tag -> Argo redeploys
env: { REG_PASS: "${{ secrets.REGISTRY_PASS }}" }
run: |
set -eu
cd src
sed -i "s#\(image: ${REGISTRY}/${OWNER}/${REPO}:\)[^[:space:]]*#\1${TAG}#" manifests/app.yaml
grep 'image:' manifests/app.yaml
if git diff --quiet; then echo "manifest already at ${TAG}"; exit 0; fi
git config user.email "ci@sovereign.local"
git config user.name "Sovereign CI"
git commit -am "ci: deploy ${TAG} [skip ci]"
git push "http://${OWNER}:${REG_PASS}@${REGISTRY}/${OWNER}/${REPO}.git" HEAD:main