Skip to content

Commit 78c079e

Browse files
authored
fix tag_release (internetarchive#11143)
* fix deploys: tag_release, cleandirs
1 parent 4e42cd1 commit 78c079e

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

scripts/deployment/deploy.sh

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
clean_exit() {
4-
if [ -n "$DEPLOY_DIR" ]; then
4+
if [ -d "$DEPLOY_DIR" ]; then
55
cleanup "$DEPLOY_DIR"
66
fi
77
exit 1
@@ -233,6 +233,11 @@ deploy_olsystem() {
233233
done
234234
echo -e "No changes found in the $REPO repo on the servers.\n"
235235

236+
cd $DEPLOY_DIR
237+
if [ -d "$DEPLOY_DIR/$REPO_NEW" ]; then
238+
cleanup "$DEPLOY_DIR/$REPO_NEW"
239+
fi
240+
236241
# Get the latest code
237242
echo -ne "Cloning $REPO repo ... "
238243
git clone --depth=1 "$CLONE_URL" $REPO_NEW 2> /dev/null
@@ -350,6 +355,12 @@ deploy_openlibrary() {
350355
echo "[Now] Deploying openlibrary"
351356

352357
cd $DEPLOY_DIR
358+
if [ -d "$DEPLOY_DIR/openlibrary" ]; then
359+
cleanup "$DEPLOY_DIR/openlibrary"
360+
fi
361+
if [ -d "$DEPLOY_DIR/openlibrary_new" ]; then
362+
cleanup "$DEPLOY_DIR/openlibrary_new"
363+
fi
353364
echo -ne "Cloning openlibrary repo ... "
354365
git clone --depth=1 "https://github.com/internetarchive/openlibrary.git" openlibrary 2> /dev/null
355366
GIT_SHA=$(git -C openlibrary rev-parse HEAD | cut -c -7)
@@ -413,8 +424,6 @@ deploy_openlibrary() {
413424
echo "Finished production deployment at $(date)"
414425
echo "To reboot the servers, please run scripts/deployments/restart_all_servers.sh"
415426

416-
cleanup "${DEPLOY_DIR}/openlibrary"
417-
418427
echo "[Info] Skipping booklending utils; see \`deploy.sh utils\`"
419428
echo "[Next] Run review aka are_servers_in_sync.sh (~50s as of 2024-12-09):"
420429
echo "time ./scripts/deployment/deploy.sh review"
@@ -655,8 +664,6 @@ deploy_wizard() {
655664
echo ""
656665
echo "The Open Library weekly deploy is now complete. See changes here: https://github.com/internetarchive/openlibrary/releases/tag/$LATEST_TAG_NAME. Please let us know @here if anything seems broken or delightful!"
657666
fi
658-
659-
cleanup "$DEPLOY_DIR"
660667
}
661668

662669
# See deployment documentation at https://github.com/internetarchive/olsystem/wiki/Deployments
@@ -692,3 +699,8 @@ else
692699
echo "e.g: time SERVER_SUFFIX='.us.archive.org' ./scripts/deployment/deploy.sh [command]"
693700
exit 1
694701
fi
702+
703+
# In all cases, cleanup upon success
704+
if [ -d "$DEPLOY_DIR" ]; then
705+
cleanup "$DEPLOY_DIR"
706+
fi

0 commit comments

Comments
 (0)