tvl-depot/ops/deploy-whitby/deploy-whitby.sh
Vincent Ambo 9c025d62a0 refactor(deploy-whitby): use nvd instead of nix-diff
nvd only shows us changed versions of packages, as well as
added/removed packages, which means that for the majority of depot
packages nothing will be displayed

however, the current output of nix-diff is not usable anyways, so
having something that can be looked at is better than nothing

Change-Id: Iefbd8139c7ccf5c88ed1209897abdb2ae9302e91
Reviewed-on: https://cl.tvl.fyi/c/depot/+/4868
Autosubmit: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
2022-01-13 08:14:00 +00:00

46 lines
1.2 KiB
Bash
Executable file

#!/usr/bin/env bash
set -Ceuo pipefail
HTML_ROOT="${HTML_ROOT:-/var/html/deploys.tvl.fyi}"
URL_BASE="${URL_BASE:-https://deploys.tvl.fyi/diff}"
IRCCAT_PORT="${IRCCAT_PORT:-4722}"
drv_hash() {
basename "$1" | sed 's/-.*//'
}
new_rev="$1"
if [ -z "$new_rev" ]; then
>&2 echo "Usage: $0 <new_rev>"
exit 1
fi
if [ -d "/tmp/deploy.worktree" ]; then
>&2 echo "/tmp/deploy.worktree exists - exiting in case another deploy is currently running"
exit 1
fi
worktree_dir=/tmp/worktree_dir
cleanup() {
rm -rf "$worktree_dir"
}
trap cleanup EXIT
git clone https://cl.tvl.fyi/depot "$worktree_dir" --reference /depot
git -C "$worktree_dir" checkout "$new_rev"
current=$(nix show-derivation /run/current-system | jq -r 'keys | .[0]')
new=$(nix-instantiate -A ops.nixos.whitbySystem "$worktree_dir")
diff_filename="$(drv_hash "$current")..$(drv_hash "$new").html"
nvd --color always diff "$current" "$new" \
| ansi2html \
>| "$HTML_ROOT/diff/$diff_filename"
chmod a+r "$HTML_ROOT/diff/$diff_filename"
echo "#tvl whitby is being deployed! system diff: $URL_BASE/$diff_filename" \
| nc -w 5 -N localhost "$IRCCAT_PORT"
# TODO(grfn): Actually do the deploy