xin/ci

37 lines
675 B
Plaintext
Raw Normal View History

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-31 14:26:29 -07:00
start_ci
2023-01-29 08:29:43 -07:00
2023-01-31 05:23:20 -07:00
trap ci_error INT TERM
2023-01-29 10:01:15 -07:00
2023-01-31 05:23:20 -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-31 05:23:20 -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-31 05:23:20 -07:00
if [ $can_sign != 1 ]; then
echo "Can't find signing key."
exit 1
2023-01-29 08:52:54 -07:00
fi
2023-01-31 05:23:20 -07:00
2023-01-31 16:28:08 -07:00
git pull || handle_pull_fail
if [ "${1}" = "update" ]; then
git checkout -b "${ci_branch}" || handle_co_fail
nix flake update --commit-lock-file || handle_update_fail
nix flake check || handle_check_fail
git checkout main || handle_co_fail
git merge "${ci_branch}" || handle_merge_fail
git push || handle_push_fail
else
nix flake check || handle_check_fail
fi
finish