Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions ceph-website-prs/build/build
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ set -ex
env

BRANCH=$(echo $GIT_BRANCH | sed 's:.*/::')
if [ "$BRANCH" = "main" ]; then
echo "branch must not be named 'main', exiting"
exit 1
fi

set +e
export NVM_DIR="$HOME/.nvm"
Expand All @@ -18,16 +22,14 @@ npm ci

npm run build:development

if [ "$BRANCH" = "main" ]; then
echo "branch must not be named 'main', exiting"
exit 1
fi
# This will support "/" and "." in branch names - specific usecase being depadabot branches
OUTPUT_DIR=$(echo "$BRANCH" | tr '/.' '-')

if [ ! -d /opt/www/${BRANCH} ]; then
mkdir -p /opt/www/${BRANCH}
if [ ! -d /opt/www/${OUTPUT_DIR} ]; then
mkdir -p /opt/www/${OUTPUT_DIR}
fi

rsync -av --delete-after dist/ /opt/www/${BRANCH}/
rsync -av --delete-after dist/ /opt/www/${OUTPUT_DIR}/

echo "===== Begin pruning old builds ====="
old_builds=$(find /opt/www/ -maxdepth 1 -not -path "/opt/www/main" -type d -mtime +90 | sed 's:.*/::')
Expand All @@ -42,4 +44,4 @@ echo "===== Done pruning old builds ====="
# This just makes the last `echo` line not repeat
{ set +x; } 2>/dev/null

echo "Success! This site is available at https://${BRANCH}.ceph.io."
echo "Success! This site is available at https://${OUTPUT_DIR}.ceph.io."