GitOps Lifecycle Hooks
Run a script from your repository before a Git-synced project deploys.
Lifecycle hooks run a script from your repository before Arcane deploys a Git Sync Pull project. Use one to prepare the workspace, such as decrypting secrets, generating config, or checking files.
Requirements
Section titled “Requirements”- An admin has enabled lifecycle hooks.
- The sync uses Pull, targets a project, and has Sync Files on. Push and Swarm stack syncs don’t run hooks.
- You have
gitops:lifecycle. - The script is inside the synced project directory, and the runner image has its interpreter and tools.
Enable lifecycle hooks
Section titled “Enable lifecycle hooks”- Open Settings → Security → Lifecycle Hooks.
- Turn on Enable Lifecycle Hooks.
- Set a default Runner Image, such as
alpine:latest, with your scripts’ tools. Syncs can override it. - Set Max Timeout (seconds) to cap per-sync hook runtimes;
0removes the cap. - Save.
Configure a pre-deploy hook on a sync
Section titled “Configure a pre-deploy hook on a sync”- In Git Syncs, create or edit a Pull sync with Target Type set to Project.
- Expand Pre-deploy script and set Script path, e.g.
scripts/pre-deploy.sh. - Turn on Sync Files.
- Optional: set Runner image to override the environment default.
- Set Timeout (seconds). Leave Network as
noneunless the script needs network access. - Optional: add environment variables and extra mounts, then save.
The script runs before each deploy that follows a sync. If it exits non-zero, times out, or can’t start, the deploy stops.
Script path and runner behavior
Section titled “Script path and runner behavior”Arcane mounts the workspace into the runner and runs the script directly, clearing the image’s entrypoint. The shebang picks the interpreter, so commit the script as executable and use an interpreter in the runner image:
#!/bin/shset -eu
echo "Preparing project files"Network mode
Section titled “Network mode”The default, none, blocks network access. Change it only when needed:
bridgefor normal outbound network accesshostwhen the script must use the host network- a Docker network name when the script must reach a specific network
Environment variables
Section titled “Environment variables”Environment variables pass static values to the runner, one KEY=VALUE line each, as in a .env file. Keys use shell-style names:
SOPS_AGE_KEY_FILE=/run/secrets/age.keyCONFIG_ENV=productionExtra mounts
Section titled “Extra mounts”Extra mounts give the hook host files outside the workspace, one per line in Docker src:tgt[:ro|:rw] form:
/srv/arcane/secrets:/run/secrets:roSource and target must be absolute paths. Prefer read-only unless the script must write there.
Check the last run
Section titled “Check the last run”When a sync doesn’t deploy, check the last hook run on the sync: run time, status (success, failed, or timeout), and truncated combined stdout and stderr. Store hook logs elsewhere for long-term use.