This commit is contained in:
1 parent
c4bf6488d0
commit
c57a894d7a
1 file changed
+62
-29
@@ -1,4 +1,5 @@
|
|||||||
name: Remote Build and Deploy
|
name: Remote Build and Deploy
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
@@ -7,49 +8,81 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Deploying via SSH connection to VPS Host
|
- name: Check out pushed commit
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Create release archive
|
||||||
|
run: |
|
||||||
|
set -Eeuo pipefail
|
||||||
|
git archive \
|
||||||
|
--format=tar.gz \
|
||||||
|
--output=atomcms-release.tar.gz \
|
||||||
|
"${GITHUB_SHA:-HEAD}"
|
||||||
|
|
||||||
|
- name: Upload release to VPS
|
||||||
|
uses: appleboy/[email protected]
|
||||||
|
with:
|
||||||
|
host: "172.20.2.1"
|
||||||
|
username: "root"
|
||||||
|
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
|
port: 22
|
||||||
|
source: "atomcms-release.tar.gz"
|
||||||
|
target: "/tmp"
|
||||||
|
overwrite: true
|
||||||
|
|
||||||
|
- name: Install and deploy on VPS
|
||||||
uses: appleboy/[email protected]
|
uses: appleboy/[email protected]
|
||||||
with:
|
with:
|
||||||
host: "172.20.2.1"
|
host: "172.20.2.1"
|
||||||
username: "root"
|
username: "root"
|
||||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
port: 22
|
port: 22
|
||||||
|
command_timeout: 20m
|
||||||
script: |
|
script: |
|
||||||
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
readonly APP_DIR="/var/www/atom-nexst"
|
||||||
|
readonly RELEASE="/tmp/atomcms-release.tar.gz"
|
||||||
|
|
||||||
echo "--- Starting EPIC WEB CONTROL Deployment ---"
|
echo "--- Starting EPIC WEB CONTROL Deployment ---"
|
||||||
|
|
||||||
# 1. Navigate to your project directory on the VPS
|
|
||||||
cd /var/www/atom-nexst/
|
|
||||||
|
|
||||||
# 2. Synchronize the application files via Git
|
|
||||||
git fetch origin
|
|
||||||
git reset --hard origin/main
|
|
||||||
|
|
||||||
# --- CLEAN-UP STEP ---
|
|
||||||
echo "--- Moving or removing specific items ---"
|
|
||||||
# rm -rf /var/www/atom-nexst/directory-name
|
|
||||||
|
|
||||||
# Install missing node_modules based on updated package.json
|
|
||||||
echo "--- Installing Dependencies ---"
|
|
||||||
pnpm install --frozen-lockfile
|
|
||||||
|
|
||||||
# Load environment variables from .env file for the next steps
|
test -d "$APP_DIR"
|
||||||
export $(grep -v '^#' .env | xargs)
|
test -f "$APP_DIR/.env"
|
||||||
|
test -f "$RELEASE"
|
||||||
|
|
||||||
|
cd "$APP_DIR"
|
||||||
|
test "$PWD" = "$APP_DIR"
|
||||||
|
|
||||||
|
echo "--- Updating Application Files ---"
|
||||||
|
|
||||||
|
# Preserve .env, storage and node_modules.
|
||||||
|
# Remove source directories so deleted files cannot remain on VPS.
|
||||||
|
rm -rf -- src public prisma scripts
|
||||||
|
|
||||||
|
tar -xzf "$RELEASE" -C "$APP_DIR"
|
||||||
|
rm -f -- "$RELEASE"
|
||||||
|
|
||||||
|
echo "--- Preparing pnpm ---"
|
||||||
|
corepack enable
|
||||||
|
corepack prepare [email protected] --activate
|
||||||
|
|
||||||
|
echo "--- Installing Locked Dependencies ---"
|
||||||
|
pnpm install --frozen-lockfile --prod=false
|
||||||
|
|
||||||
|
echo "--- Generating Prisma Client ---"
|
||||||
|
pnpm prisma:generate
|
||||||
|
|
||||||
# 3. Run database migrations natively
|
|
||||||
echo "--- Running Database Migrations ---"
|
echo "--- Running Database Migrations ---"
|
||||||
pnpm db:migrate
|
pnpm db:migrate
|
||||||
|
|
||||||
# Regenerate Prisma Client to update types (Fixes userWatch error)
|
|
||||||
echo "--- Generating Prisma Client Types ---"
|
|
||||||
pnpm prisma generate
|
|
||||||
|
|
||||||
# 4. Compile the updated distribution assets
|
|
||||||
echo "--- Building Application ---"
|
echo "--- Building Application ---"
|
||||||
|
rm -rf -- .next
|
||||||
pnpm build
|
pnpm build
|
||||||
|
|
||||||
# 5. Restart the host background service cleanly
|
|
||||||
echo "--- Restarting Atom Nexst Service ---"
|
echo "--- Restarting Atom Nexst Service ---"
|
||||||
sudo systemctl restart atom-nexst.service
|
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