Deploy the stack from the repo's compose.yaml via Gitea Actions
- deploy.yml gets a deploy job after the build: pull, compose up on Unraid through the runner's Docker socket, then a health gate on eb-blazor /health from inside proxynet; docs-only pushes trigger nothing, manual runs allowed - STRATO_DYNDNS_PASSWORD comes from a Gitea secret instead of the Compose Manager env file - restart: always, because Unraid stops containers explicitly on shutdown and unless-stopped would leave the stack down after a reboot; the dev overlay turns it off - Docs describe the automatic rollout and the one-time switch away from the Compose Manager stack Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4968b62f06
commit
05b1666f81
5 files changed
+152
-99
No files matched your search
+78
-11
@@ -1,25 +1,41 @@
|
||||
# Builds the production image on every push to main and pushes it to the Gitea
|
||||
# registry, tagged with :latest AND the short commit SHA (for rollback) -- the
|
||||
# same tagging scheme as scripts/release.sh, but run by the act_runner instead
|
||||
# of by hand.
|
||||
# Builds the production image on every push to main, pushes it to the Gitea
|
||||
# registry (tagged :latest AND the short commit SHA, for rollback) and deploys the
|
||||
# stack on Unraid from the repo's compose.yaml -- the repo is the only copy of the
|
||||
# compose file; there is no duplicate in the Compose Manager.
|
||||
#
|
||||
# It does NOT deploy: pulling and starting the new :latest on Unraid stays a
|
||||
# manual, deliberate step (Compose Down/Up). Auto-deploy via Watchtower is an
|
||||
# open item in docs/deployment.md and needs a health gate first, so a broken
|
||||
# page can never go live unnoticed.
|
||||
# The deploy works because the act_runner runs ON Unraid and hands its Docker
|
||||
# socket to the job: every `docker` command here talks to the Unraid daemon, so
|
||||
# absolute paths in compose.yaml (the pb_data bind mount) are host paths.
|
||||
#
|
||||
# `docker compose up -d` only recreates containers whose image or config changed:
|
||||
# a new image restarts eb-blazor for a few seconds, eb-pocketbase and eb-ddns keep
|
||||
# running. Content lives in PocketBase and is never touched by a deploy.
|
||||
#
|
||||
# Required repository secrets (Gitea -> repo -> Settings -> Actions -> Secrets):
|
||||
# REGISTRY_USER the registry username (e.g. Tom)
|
||||
# REGISTRY_TOKEN a Gitea access token with package:write -- NOT the password
|
||||
# REGISTRY_USER the registry username (e.g. Tom)
|
||||
# REGISTRY_TOKEN a Gitea access token with package:write -- NOT the password
|
||||
# STRATO_DYNDNS_PASSWORD the DynDNS password for eb-ddns (docs/deployment.md)
|
||||
|
||||
name: Build and push image
|
||||
name: Build and deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
# Docs alone change neither the image nor the stack.
|
||||
paths-ignore:
|
||||
- "docs/**"
|
||||
- "**/*.md"
|
||||
# Manual run from Gitea (Actions tab), e.g. to redeploy after a server restart.
|
||||
workflow_dispatch:
|
||||
|
||||
# Two quick pushes must not deploy over each other; the later one waits.
|
||||
concurrency:
|
||||
group: deploy
|
||||
cancel-in-progress: false
|
||||
|
||||
env:
|
||||
IMAGE: gitea.anticarnist.de/tom/elternbeirat
|
||||
COMPOSE_VERSION: v2.39.4
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -52,3 +68,54 @@ jobs:
|
||||
tags: |
|
||||
${{ env.IMAGE }}:latest
|
||||
${{ env.IMAGE }}:${{ steps.sha.outputs.short }}
|
||||
|
||||
deploy:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out the source
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# The job image ships the Docker CLI (the build needs it) but not
|
||||
# necessarily the compose plugin; install a pinned one if it is missing.
|
||||
- name: Ensure docker compose
|
||||
run: |
|
||||
docker compose version && exit 0
|
||||
mkdir -p ~/.docker/cli-plugins
|
||||
curl -fsSL -o ~/.docker/cli-plugins/docker-compose \
|
||||
"https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-linux-x86_64"
|
||||
chmod +x ~/.docker/cli-plugins/docker-compose
|
||||
docker compose version
|
||||
|
||||
# The image is private; the pull below runs with this job's login.
|
||||
- name: Log in to the Gitea registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: gitea.anticarnist.de
|
||||
username: ${{ secrets.REGISTRY_USER }}
|
||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||
|
||||
# An explicit pull: `up` alone keeps a local :latest and would not notice
|
||||
# the image the build job just pushed.
|
||||
- name: Pull and start the stack
|
||||
env:
|
||||
STRATO_DYNDNS_PASSWORD: ${{ secrets.STRATO_DYNDNS_PASSWORD }}
|
||||
run: |
|
||||
docker compose -f compose.yaml pull
|
||||
docker compose -f compose.yaml up -d --wait --remove-orphans
|
||||
|
||||
# /health answers 200 only when the app runs AND reaches PocketBase. It is
|
||||
# checked from inside proxynet, the same way NPM reaches the app. A failure
|
||||
# marks the run red; the rollback stays a deliberate step (docs/deployment.md).
|
||||
- name: Health gate
|
||||
run: |
|
||||
for attempt in $(seq 1 30); do
|
||||
if docker run --rm --network proxynet busybox:1.37 \
|
||||
wget -qO- http://eb-blazor:8080/health; then
|
||||
exit 0
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
echo "eb-blazor did not report healthy within 60 seconds." >&2
|
||||
docker logs --tail 50 eb-blazor >&2
|
||||
exit 1
|
||||
Reference in new issue
Block a user