comin, ci: Add confirmation and rollback functionality to deployments

This commit is contained in:
SebastianStork 2026-03-06 18:55:05 +01:00
parent eb021286a5
commit 09e9cd5811
Signed by: SebastianStork
SSH key fingerprint: SHA256:tRrGdjYOwgHxpSc/wTOZQZEjxcb15P0tyXRsbAfd+2Q
2 changed files with 78 additions and 6 deletions

View file

@ -1,11 +1,32 @@
{
config,
inputs,
pkgs,
lib,
...
}:
let
cfg = config.custom.services.comin;
postDeploymentScript =
pkgs.writeShellApplication {
name = "comin-post-deployment";
runtimeInputs = [ pkgs.git ];
text = ''
if [[ "$COMIN_STATUS" != "done" ]]; then
echo "Deployment not successful (status: $COMIN_STATUS), skipping branch update"
exit 0
fi
token=$(cat "''${CREDENTIALS_DIRECTORY}/git-push-token")
repo_url="https://x-access-token:$token@github.com/SebastianStork/nixos-config.git"
git push --force "$repo_url" "$COMIN_GIT_SHA:refs/heads/deployed/$COMIN_HOSTNAME"
echo "Updated deployed/$COMIN_HOSTNAME to $COMIN_GIT_SHA"
'';
}
|> lib.getExe;
in
{
imports = [ inputs.comin.nixosModules.comin ];
@ -35,6 +56,7 @@ in
listen_address = "127.0.0.1";
port = cfg.metricsPort;
};
postDeploymentCommand = postDeploymentScript;
};
};
}