This commit is contained in:
parent
67b93210cf
commit
682f2e4e84
1 changed files with 45 additions and 0 deletions
45
.forgejo/workflows/ci.yml
Normal file
45
.forgejo/workflows/ci.yml
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue