infra-controller/scripts/deploy-app
Jeremie Fraeys 6ca0219902
Some checks failed
Deploy / deploy (push) Failing after 9s
Deploy infra-controller to services server
2026-01-23 14:01:54 -05:00

41 lines
795 B
Bash

#!/usr/bin/env bash
set -euo pipefail
APP_NAME="${1:-}"
GIT_REF="${2:-}"
if [[ -z "$APP_NAME" || -z "$GIT_REF" ]]; then
echo "usage: deploy-app <app_name> <git_ref>" >&2
exit 2
fi
if ! [[ "$APP_NAME" =~ ^[A-Za-z0-9._-]+$ ]]; then
echo "invalid app name: $APP_NAME" >&2
exit 2
fi
if ! [[ "$GIT_REF" =~ ^[0-9a-fA-F]{7,40}$ ]]; then
echo "invalid git ref: $GIT_REF" >&2
exit 2
fi
APP_DIR="/srv/apps/$APP_NAME"
if [[ ! -d "$APP_DIR/.git" ]]; then
echo "app repo not present at $APP_DIR; clone it first (or extend deploy-app to clone)" >&2
exit 1
fi
cd "$APP_DIR"
git fetch --all --prune
git checkout -f "$GIT_REF"
git submodule update --init --recursive
if [[ -x "./deploy.sh" ]]; then
./deploy.sh
else
echo "ERROR: deploy.sh missing or not executable" >&2
exit 1
fi