From e4b26983800029b669ed06584027afc90da69859 Mon Sep 17 00:00:00 2001 From: "jeremy@jermolene.com" Date: Fri, 1 Apr 2022 11:04:18 +0100 Subject: [PATCH] CI: Only commit if there are changes Suggested by https://github.community/t/ignore-working-tree-clean/193304 We also get rid of `set -e` to simplify things --- bin/build-tw-org.sh | 17 +++++++---------- bin/ci-push.sh | 19 ++++++++----------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/bin/build-tw-org.sh b/bin/build-tw-org.sh index eb76baa85..a7b0c4426 100755 --- a/bin/build-tw-org.sh +++ b/bin/build-tw-org.sh @@ -84,14 +84,11 @@ rm $TWORG_BUILD_OUTPUT/build.tid || exit 1 # Push output back to GitHub -# Exit script immediately if any command fails -set -e - -pushd $TWORG_BUILD_OUTPUT -git config --global user.email "actions@github.com" -git config --global user.name "GitHub Actions" -git add -A . -git commit --message "GitHub build: $GITHUB_RUN_NUMBER of $TW5_BUILD_BRANCH ($(date +'%F %T %Z'))" -git remote add deploy "https://$GH_TOKEN@github.com/TiddlyWiki/tiddlywiki.org-gh-pages.git" &>/dev/null -git push deploy main &>/dev/null +pushd $TWORG_BUILD_OUTPUT || exit 1 +git config --global user.email "actions@github.com" || exit 1 +git config --global user.name "GitHub Actions" || exit 1 +git add -A . || exit 1 +git diff --exit-code || git commit --message "GitHub build: $GITHUB_RUN_NUMBER of $TW5_BUILD_BRANCH ($(date +'%F %T %Z'))" || exit 1 +git remote add deploy "https://$GH_TOKEN@github.com/TiddlyWiki/tiddlywiki.org-gh-pages.git" &>/dev/null || exit 1 +git push deploy main &>/dev/null || exit 1 popd diff --git a/bin/ci-push.sh b/bin/ci-push.sh index dff297c80..55b7f8be0 100755 --- a/bin/ci-push.sh +++ b/bin/ci-push.sh @@ -2,14 +2,11 @@ # Push output back to GitHub -# Exit script immediately if any command fails -set -e - -cd output -git config --global user.email "actions@github.com" -git config --global user.name "GitHub Actions" -git add -A . -git commit --message "GitHub build: $GITHUB_RUN_NUMBER of $TW5_BUILD_BRANCH ($(date +'%F %T %Z'))" -git remote add deploy "https://$GH_TOKEN@github.com/Jermolene/jermolene.github.io.git" &>/dev/null -git push deploy master &>/dev/null -cd .. +cd output || exit 1 +git config --global user.email "actions@github.com" || exit 1 +git config --global user.name "GitHub Actions" || exit 1 +git add -A . || exit 1 +git diff --exit-code || git commit --message "GitHub build: $GITHUB_RUN_NUMBER of $TW5_BUILD_BRANCH ($(date +'%F %T %Z'))" || exit 1 +git remote add deploy "https://$GH_TOKEN@github.com/Jermolene/jermolene.github.io.git" || exit 1 +git push deploy master || exit 1 +cd .. || exit 1