xin/ci

41 lines
688 B
Bash
Executable File

#!/usr/bin/env sh
. ./common.sh
CMD=${1:-""}
set -eu
NAME="CI"
SESS="-s ${NAME}"
if tmux ls | grep -q "^${NAME}:"; then
tmux -u2 at -t "${NAME}"
else
tmux -2 new-session -d ${SESS}
fi
tmux -2 attach-session -t "$NAME"
trap ci_error INT TERM
if [ "$CMD" = "run" ]; then
ci_branch=$(date +"%Y%m%dT%H%M%S%z")
can_sign=0
for i in $(ssh-add -L | awk '{print $NF}'); do
grep -q $i .allowed_signers && can_sign=1
done
if [ $can_sign != 1 ]; then
echo "Can't find signing key."
exit 1
fi
git checkout -b "${ci_branch}" || handle_co_fail
nix flake update --commit-lock-file || handle_update_fail
nix flake check || handle_check_fail
else
tmux send "./ci run" ENTER
fi