From 25b251b15c9264b041036505214e5c2cb5725253 Mon Sep 17 00:00:00 2001 From: boilerrat <128boilerrat@gmail.com> Date: Sun, 16 Mar 2025 14:41:14 -0400 Subject: [PATCH] Update deployment script to use GitHub portfolio repository --- deploy-website.sh | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/deploy-website.sh b/deploy-website.sh index 900547e..e65f147 100755 --- a/deploy-website.sh +++ b/deploy-website.sh @@ -1,6 +1,6 @@ #!/bin/bash -# This script deploys the website to the VPS +# This script deploys the portfolio website from GitHub to the VPS # Load environment variables if [ -f .env ]; then @@ -22,33 +22,45 @@ SCP_CMD="sshpass -p \"$SERVER_PASSWORD\" scp -o StrictHostKeyChecking=no" # Set variables REMOTE_DIR="/var/www/boilerhaus.org" -LOCAL_DIR="." +GITHUB_REPO="https://github.com/boilerrat/portfolio.git" +TEMP_DIR="./portfolio-temp" # Create a temporary directory for the website files echo "Creating temporary directory..." -mkdir -p ./deploy-temp +mkdir -p $TEMP_DIR +cd $TEMP_DIR -# Copy necessary files to the temporary directory -echo "Copying website files..." -cp -r index.html css dist ./deploy-temp/ +# Clone the repository +echo "Cloning portfolio repository from GitHub..." +git clone $GITHUB_REPO . -# Create a tarball of the website files -echo "Creating tarball..." -tar -czf website.tar.gz -C ./deploy-temp . +# Install dependencies +echo "Installing dependencies..." +npm install + +# Build the project +echo "Building the project..." +npm run build + +# Create a tarball of the built files +echo "Creating tarball of the built files..." +cd dist +tar -czf ../../portfolio-dist.tar.gz . +cd ../.. # Upload the tarball to the server echo "Uploading to server..." -eval "$SCP_CMD website.tar.gz $SERVER_USER@$SERVER_IP:/tmp/" +eval "$SCP_CMD portfolio-dist.tar.gz $SERVER_USER@$SERVER_IP:/tmp/" # Extract the tarball on the server echo "Extracting files on server..." eval "$SSH_CMD \"mkdir -p $REMOTE_DIR && \ - tar -xzf /tmp/website.tar.gz -C $REMOTE_DIR && \ + tar -xzf /tmp/portfolio-dist.tar.gz -C $REMOTE_DIR && \ chown -R www-data:www-data $REMOTE_DIR && \ - rm /tmp/website.tar.gz\"" + rm /tmp/portfolio-dist.tar.gz\"" # Clean up local files echo "Cleaning up..." -rm -rf ./deploy-temp website.tar.gz +rm -rf $TEMP_DIR portfolio-dist.tar.gz -echo "Website deployed successfully!" \ No newline at end of file +echo "Portfolio website deployed successfully!" \ No newline at end of file