## Was Woodpecker-Plugin `deploy` (`git.uesome.de/actions/ci-cd/deploy`): schreibt ein gepushtes dev- oder beta-Image mit Digest nach `tanztee/oumta-deploy`. Die Umgebung entscheidet dort `ci/deploy-image.sh` anhand des Tags (`-dev.` → dev, `-beta.` → beta, sonst nichts; prod nur per PR). Digest per `crane`, kein Docker-Daemon nötig (dafür tanztee/oumta-deploy#20). - `woodpecker/deploy/`: Dockerfile (`alpine:3.20`, bash, git, crane) und `deploy.sh` - `.woodpecker/plugins.yaml`: Push/PR mit Änderungen unter `woodpecker/deploy/**` → nur Probe-Build (`dry_run`, ohne Secrets); Tag `deploy-vX.Y.Z` → Push als `:vX.Y.Z` - `README.md`: Abschnitt „Woodpecker plugins“ mit Settings und Beispiel Das Token von `oumta-ci` steht nur im Credential-Helper, nicht in URL oder Config. ## Getestet (lokal, crane als Stub, gegen Kopie von oumta-deploy `a74c73d`) | Fall | Ergebnis | | --- | --- | | `v2.0.1-dev.…`, `AUTH_IMAGE` | `deploy(dev): oumta-auth …` | | `v2.0.9-beta.7`, `APP_V{major}_IMAGE` | `APP_V2_IMAGE` in beta | | `v2.0.1` | nichts zu tun, Exit 0 | | keyklo, `envs: dev beta` | zwei Commits | | gleicher Tag erneut | „bereits aktuell“ | | ohne `deploy_token` | Abbruch mit Meldung | Offen: echter Lauf gegen Registry und Gitea per HTTPS. ## Vor dem ersten Lauf in Woodpecker 1. `actions/ci-cd` aktivieren. 2. Repo-Secrets `registry_username`/`registry_password` (Schreibrecht auf Pakete der Org `actions`), nur Event `tag`, nur Image `woodpeckerci/plugin-docker-buildx`. 3. Prüfen, ob `plugin-docker-buildx:6.1.2` privilegiert laufen darf (`WOODPECKER_PLUGINS_PRIVILEGED`). Tag `deploy-v1.0.0` erst nach dem Merge und grünem Probe-Build. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Reviewed-on: #1
36 lines
1.5 KiB
Bash
Executable File
36 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Woodpecker plugin "deploy": writes the pushed image with its digest to
|
|
# oumta-deploy. ci/deploy-image.sh there decides the environment from the tag
|
|
# (-dev. -> dev, -beta. -> beta, anything else -> nothing).
|
|
set -euo pipefail
|
|
|
|
die() { echo "deploy: $*" >&2; exit 1; }
|
|
|
|
VAR=${PLUGIN_VAR:?settings.var is missing}
|
|
REGISTRY=${PLUGIN_REGISTRY:-git.uesome.de}
|
|
IMAGE=${PLUGIN_IMAGE:-$REGISTRY/${CI_REPO:?CI_REPO is missing}}
|
|
TAG=${PLUGIN_TAG:-${CI_COMMIT_TAG:-}}
|
|
DEPLOY_USER=${PLUGIN_DEPLOY_USER:-oumta-ci}
|
|
DEPLOY_REPO=${PLUGIN_DEPLOY_REPO:-https://git.uesome.de/tanztee/oumta-deploy.git}
|
|
[[ -n $TAG ]] || die "no tag (settings.tag or tag event)"
|
|
[[ -n ${PLUGIN_DEPLOY_TOKEN:-} ]] || die "settings.deploy_token is missing"
|
|
|
|
major=${TAG#v}; major=${major%%.*}
|
|
VAR=${VAR//\{major\}/$major}
|
|
|
|
if [[ -n ${PLUGIN_REGISTRY_USERNAME:-} ]]; then
|
|
crane auth login "$REGISTRY" -u "$PLUGIN_REGISTRY_USERNAME" --password-stdin \
|
|
<<<"${PLUGIN_REGISTRY_PASSWORD:?settings.registry_password is missing}" >/dev/null
|
|
fi
|
|
|
|
# Token only via credential helper, never in a URL or config, so no log shows it
|
|
helper='!f() { echo "username=$DEPLOY_USER"; echo "password=$PLUGIN_DEPLOY_TOKEN"; }; f'
|
|
export DEPLOY_USER PLUGIN_DEPLOY_TOKEN
|
|
work=$(mktemp -d)
|
|
git -c credential.helper="$helper" clone --quiet "$DEPLOY_REPO" "$work/oumta-deploy"
|
|
git -C "$work/oumta-deploy" config credential.helper "$helper"
|
|
|
|
export DEPLOY_ENVS=${PLUGIN_ENVS:-}
|
|
export SOURCE_REPO=${CI_REPO:-} SOURCE_COMMIT=${CI_COMMIT_SHA:-}
|
|
"$work/oumta-deploy/ci/deploy-image.sh" "$VAR" "${IMAGE,,}:$TAG"
|