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