Last active
August 6, 2024 16:32
-
-
Save osbre/221189736e6a158a7bb52833ac0d316d to your computer and use it in GitHub Desktop.
(ported from freek.dev's envoy.blade.php setup)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Configuration | |
SITE_DIR="/home/forge/staging.streampot.io" | |
GIT_REPO="git@github.com:StreamPot/SaaS.git" | |
RELEASES_DIR="$SITE_DIR/releases" | |
PERSISTENT_DIR="$SITE_DIR/persistent" | |
CURRENT_DIR="$SITE_DIR/current" | |
RELEASE_NAME=$(date +"%Y%m%d-%H%M%S") | |
NEW_RELEASE_DIR="$RELEASES_DIR/$RELEASE_NAME" | |
# Ensure required directories exist | |
mkdir -p $RELEASES_DIR $PERSISTENT_DIR/storage | |
# Clone repository | |
echo "π Cloning repository..." | |
git clone --depth 1 $GIT_REPO --branch "$FORGE_SITE_BRANCH" "$NEW_RELEASE_DIR" | |
# Configure sparse checkout | |
cd "$NEW_RELEASE_DIR" || exit | |
git config core.sparsecheckout true | |
echo "*" > .git/info/sparse-checkout | |
echo "!storage" >> .git/info/sparse-checkout | |
echo "!public/build" >> .git/info/sparse-checkout | |
git read-tree -mu HEAD | |
# Mark release | |
echo "$RELEASE_NAME" > "$NEW_RELEASE_DIR"/public/release-name.txt | |
# Set up environment and dependencies | |
echo "π Setting up environment and running Composer..." | |
ln -nfs $SITE_DIR/.env "$NEW_RELEASE_DIR"/.env | |
#ln -nfs $SITE_DIR/auth.json "$NEW_RELEASE_DIR"/auth.json | |
cd "$NEW_RELEASE_DIR" || exit | |
$FORGE_COMPOSER install --no-dev --no-interaction --prefer-dist --optimize-autoloader | |
# Run PNPM | |
echo "π¦ Running PNPM..." | |
/home/forge/.local/share/pnpm/pnpm i && /home/forge/.local/share/pnpm/pnpm build | |
# Update symlinks | |
echo "π Updating symlinks..." | |
ln -nfs $PERSISTENT_DIR/storage "$NEW_RELEASE_DIR"/storage | |
#ln -nfs $PERSISTENT_DIR/uploads "$NEW_RELEASE_DIR"/public/uploads | |
#ln -nfs $PERSISTENT_DIR/storage/admin-uploads "$NEW_RELEASE_DIR"/public/admin-uploads | |
#ln -nfs $PERSISTENT_DIR/storage/og-images "$NEW_RELEASE_DIR"/public/og-images | |
#ln -nfs $PERSISTENT_DIR/fonts "$NEW_RELEASE_DIR"/public/fonts | |
# Optimize installation | |
echo "β¨ Optimizing installation..." | |
php artisan clear-compiled | |
# Backup database | |
# echo "π Backing up database..." | |
# php artisan backup:run | |
# Migrate database | |
echo "π Migrating database..." | |
php artisan migrate --force | |
# Bless new release | |
echo "π Blessing new release..." | |
ln -nfs "$NEW_RELEASE_DIR" $CURRENT_DIR | |
cd $CURRENT_DIR || exit | |
php artisan horizon:terminate | |
php artisan config:clear | |
php artisan view:clear | |
php artisan cache:clear | |
php artisan config:cache | |
php artisan route:clear | |
php artisan route:cache | |
php artisan event:cache | |
# Filament admin commands | |
php artisan icons:cache | |
php artisan filament:cache-components | |
# Restart services | |
echo "π Restarting services..." | |
sudo service $FORGE_PHP_FPM restart | |
sudo supervisorctl restart all | |
# Additional tasks | |
#php artisan schedule:sync | |
#php artisan health:check | |
# Clean old releases | |
echo "πΎ Cleaning up old releases..." | |
cd $RELEASES_DIR || exit | |
ls -dt */ | tail -n +4 | xargs -I {} rm -rf {} | |
echo "π Deployment completed successfully!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
video-of-a-problem-with-changing-deployment-script.mov
Upd: turns out this was due to emoji being present in the script. still a bug tho.