This commit is contained in:
1 parent
f9213beb9c
commit
c768d80cab
1 file changed
+20
-39
@@ -5,14 +5,9 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: atomcms-production-deploy
|
|
||||||
cancel-in-progress: false
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 30
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Deploying via SSH connection to VPS Host
|
- name: Deploying via SSH connection to VPS Host
|
||||||
@@ -22,55 +17,41 @@ jobs:
|
|||||||
username: "root"
|
username: "root"
|
||||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
port: 22
|
port: 22
|
||||||
timeout: 120s
|
|
||||||
command_timeout: 25m
|
|
||||||
script: |
|
script: |
|
||||||
set -Eeuo pipefail
|
|
||||||
|
|
||||||
readonly APP_DIR="/var/www/atom-nexst"
|
|
||||||
|
|
||||||
echo "--- Starting EPIC WEB CONTROL Deployment ---"
|
echo "--- Starting EPIC WEB CONTROL Deployment ---"
|
||||||
|
|
||||||
# 1. Navigate safely to the project directory
|
# 1. Navigate to your project directory on the VPS
|
||||||
test -d "$APP_DIR"
|
cd /var/www/atom-nexst/
|
||||||
test -f "$APP_DIR/.env"
|
|
||||||
|
|
||||||
cd "$APP_DIR"
|
# 2. Synchronize the application files via Git
|
||||||
test "$PWD" = "$APP_DIR"
|
git fetch origin
|
||||||
|
git reset --hard origin/main
|
||||||
|
|
||||||
# 2. Synchronize application files
|
# --- CLEAN-UP STEP ---
|
||||||
echo "--- Synchronizing Git Repository ---"
|
echo "--- Moving or removing specific items ---"
|
||||||
git fetch origin main
|
rm -rf /var/www/atom-nexst/directory-name
|
||||||
git reset --hard FETCH_HEAD
|
|
||||||
|
|
||||||
echo "--- Current Commit ---"
|
# Install missing node_modules based on updated package.json
|
||||||
git rev-parse HEAD
|
|
||||||
|
|
||||||
# 3. Install dependencies from the lockfile
|
|
||||||
echo "--- Installing Dependencies ---"
|
echo "--- Installing Dependencies ---"
|
||||||
corepack enable
|
pnpm install --frozen-lockfile
|
||||||
corepack prepare [email protected] --activate
|
|
||||||
pnpm install --frozen-lockfile --prod=false
|
|
||||||
|
|
||||||
# Do not export .env manually.
|
# Load environment variables from .env file for the next steps
|
||||||
# Next.js and the migration script load it themselves.
|
export $(grep -v '^#' .env | xargs)
|
||||||
|
|
||||||
# 4. Generate Prisma client
|
# 3. Run database migrations natively
|
||||||
echo "--- Generating Prisma Client ---"
|
|
||||||
pnpm prisma:generate
|
|
||||||
|
|
||||||
# 5. Run database migrations
|
|
||||||
echo "--- Running Database Migrations ---"
|
echo "--- Running Database Migrations ---"
|
||||||
pnpm db:migrate
|
pnpm db:migrate
|
||||||
|
|
||||||
# 6. Build the application
|
# Regenerate Prisma Client to update types
|
||||||
|
echo "--- Generating Prisma Client Types ---"
|
||||||
|
pnpm prisma generate
|
||||||
|
|
||||||
|
# 4. Compile the updated distribution assets
|
||||||
echo "--- Building Application ---"
|
echo "--- Building Application ---"
|
||||||
rm -rf -- "$APP_DIR/.next"
|
|
||||||
pnpm build
|
pnpm build
|
||||||
|
|
||||||
# 7. Restart and verify service
|
# 5. Restart the host background service
|
||||||
echo "--- Restarting Atom Nexst Service ---"
|
echo "--- Restarting Atom Nexst Service ---"
|
||||||
systemctl restart atom-nexst.service
|
sudo systemctl restart atom-nexst.service
|
||||||
systemctl is-active --quiet atom-nexst.service
|
|
||||||
|
|
||||||
echo "--- Deployment Completed Successfully ---"
|
echo "--- Deployment Completed Successfully ---"
|
||||||
Reference in new issue
Block a user