-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeployer.nix
34 lines (29 loc) · 1.03 KB
/
deployer.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
{ pkgs, dev-env-image }:
let
git = "${pkgs.git}/bin/git";
artifactPusher = import ./artifact-pusher.nix { inherit pkgs dev-env-image; };
image-patch-json-6902 = pkgs.writeText "image-patch.json6902.yaml" ''
- op: replace
path: /spec/template/spec/containers/0/image
value: "${dev-env-image.imageNameWithTag}"
'';
homelab-config-path = "/tmp/homelab-config-cloned";
patchPathInRepo = "k8s/dev/overlay/image-patch.json6902.yaml";
in
pkgs.writeShellScriptBin "deploy_dev_env" ''
${artifactPusher}/bin/push_artifact
rm -rf ${homelab-config-path}
${git} clone git@github.com:jali-clarke/homelab-config ${homelab-config-path}
pushd ${homelab-config-path}
${git} checkout master
rm ${patchPathInRepo}
cp ${image-patch-json-6902} ${patchPathInRepo}
${git} add ${patchPathInRepo}
if [[ -z "$(${git} --no-pager diff HEAD)" ]]; then
echo "no changes to homelab-config repo, skipping commit + push"
else
${git} commit -m "updated image to ${dev-env-image.imageNameWithTag}"
${git} push
fi
popd
''