From 8643ce6a17836adc105cafab7a517f575ccde120 Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Mon, 3 Apr 2023 19:06:41 +0200 Subject: Fix update check --- modules/auto-redeploy.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/auto-redeploy.nix b/modules/auto-redeploy.nix index fef352c..3ea187c 100644 --- a/modules/auto-redeploy.nix +++ b/modules/auto-redeploy.nix @@ -10,8 +10,14 @@ cd /Spacebar-Open-Architecture #store current commit hash currentCommit=$(git rev-parse HEAD) - #pull from git, and exit if nothing to pull - ${pkgs.git}/bin/git pull || exit 0 + git fetch --all + #check if there are any new commits + if [ $(git rev-parse HEAD) = $(git rev-parse @{u}) ]; then + echo "Already up-to-date" + exit 0 + fi + #pull new commits + git pull #send commit log to discord ${pkgs.curl}/bin/curl -H "Content-Type: application/json" -d '{"username": "${config.networking.hostName} - redeploy", "content": "```$(git log --pretty=format:"%h - %s" $currentCommit..HEAD)```"}' ${secrets.webhooks.discord.deploy} #call ./update.sh and store output (including stderr) in a file -- cgit 1.4.1