summaryrefslogtreecommitdiff
path: root/deploy.ps1
diff options
context:
space:
mode:
authortanaka takashi <isazaka@gmail.com>2026-08-29 16:20:48 +0900
committertanaka takashi <isazaka@gmail.com>2026-08-29 16:20:48 +0900
commit40290d2f2c3cb887532c8cfc4570d74e979674a7 (patch)
tree6b30af17b9e2701d8491a537f833e1d918dc81f1 /deploy.ps1
parentd768a1c738043ae673b60ca6a516c041772ede24 (diff)
記事草稿1
Diffstat (limited to 'deploy.ps1')
-rw-r--r--deploy.ps125
1 files changed, 15 insertions, 10 deletions
diff --git a/deploy.ps1 b/deploy.ps1
index da4a0dc..02089f5 100644
--- a/deploy.ps1
+++ b/deploy.ps1
@@ -232,6 +232,11 @@ release="$base/releases/$release_id"
new_link="$base/current.new"
release_created=0
+fail() {
+ echo "Remote deployment failed: $*" >&2
+ exit 1
+}
+
cleanup() {
status=$?
trap - 0
@@ -244,10 +249,10 @@ cleanup() {
}
trap cleanup 0
-test -d "$base/releases"
-test -L "$base/current"
-test -f "$base/current/index.html"
-test -f "$archive"
+[ -d "$base" ] || fail "remote base does not exist: $base"
+[ -d "$base/releases" ] || fail "releases directory does not exist: $base/releases"
+[ -L "$base/current" ] || fail "current is not a symbolic link: $base/current"
+[ -f "$archive" ] || fail "uploaded archive does not exist: $archive"
if [ -e "$release" ] || [ -L "$release" ]; then
echo "Release already exists: $release_id" >&2
@@ -255,16 +260,16 @@ if [ -e "$release" ] || [ -L "$release" ]; then
fi
if [ -e "$new_link" ] || [ -L "$new_link" ]; then
- rm -f -- "$new_link"
+ rm -f -- "$new_link" || fail "could not remove stale symlink: $new_link"
fi
-mkdir -- "$release"
+mkdir -- "$release" || fail "could not create release directory: $release"
release_created=1
-tar -xzf "$archive" -C "$release"
-test -f "$release/index.html"
+tar -xzf "$archive" -C "$release" || fail "could not extract archive into: $release"
+[ -f "$release/index.html" ] || fail "new release has no index.html: $release/index.html"
-ln -s "releases/$release_id" "$new_link"
-mv -Tf "$new_link" "$base/current"
+ln -s "releases/$release_id" "$new_link" || fail "could not create temporary symlink: $new_link"
+mv -Tf "$new_link" "$base/current" || fail "could not atomically replace current symlink"
release_created=0
'@
$remoteScript = $remoteScript.Replace("__REMOTE_BASE__", $RemoteBase)