This commit is contained in:
1 parent
3140cbbbd4
commit
f9213beb9c
1 file changed
+47
-50
@@ -11,69 +11,66 @@ concurrency:
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: shell
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
|
||||
steps:
|
||||
- name: Check out pushed commit
|
||||
uses: actions/checkout@v4
|
||||
- name: Deploying via SSH connection to VPS Host
|
||||
uses: appleboy/[email protected]
|
||||
with:
|
||||
fetch-depth: 1
|
||||
host: "172.20.2.1"
|
||||
username: "root"
|
||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
port: 22
|
||||
timeout: 120s
|
||||
command_timeout: 25m
|
||||
script: |
|
||||
set -Eeuo pipefail
|
||||
|
||||
- name: Deploy AtomCMS
|
||||
shell: bash
|
||||
run: |
|
||||
set -Eeuo pipefail
|
||||
readonly APP_DIR="/var/www/atom-nexst"
|
||||
|
||||
readonly APP_DIR="/var/www/atom-nexst"
|
||||
readonly SOURCE_DIR="${GITHUB_WORKSPACE}"
|
||||
echo "--- Starting EPIC WEB CONTROL Deployment ---"
|
||||
|
||||
echo "--- Starting EPIC WEB CONTROL Deployment ---"
|
||||
# 1. Navigate safely to the project directory
|
||||
test -d "$APP_DIR"
|
||||
test -f "$APP_DIR/.env"
|
||||
|
||||
test -n "$SOURCE_DIR"
|
||||
test -d "$SOURCE_DIR/src"
|
||||
test -f "$SOURCE_DIR/package.json"
|
||||
test -f "$SOURCE_DIR/pnpm-lock.yaml"
|
||||
cd "$APP_DIR"
|
||||
test "$PWD" = "$APP_DIR"
|
||||
|
||||
test -d "$APP_DIR"
|
||||
test -f "$APP_DIR/.env"
|
||||
test "$APP_DIR" = "/var/www/atom-nexst"
|
||||
# 2. Synchronize application files
|
||||
echo "--- Synchronizing Git Repository ---"
|
||||
git fetch origin main
|
||||
git reset --hard FETCH_HEAD
|
||||
|
||||
echo "--- Synchronizing Application Files ---"
|
||||
echo "--- Current Commit ---"
|
||||
git rev-parse HEAD
|
||||
|
||||
sudo rsync -a --delete \
|
||||
--exclude=".git/" \
|
||||
--exclude=".env" \
|
||||
--exclude=".next/" \
|
||||
--exclude="node_modules/" \
|
||||
--exclude="storage/" \
|
||||
--exclude="docs/" \
|
||||
"$SOURCE_DIR/" "$APP_DIR/"
|
||||
# 3. Install dependencies from the lockfile
|
||||
echo "--- Installing Dependencies ---"
|
||||
corepack enable
|
||||
corepack prepare [email protected] --activate
|
||||
pnpm install --frozen-lockfile --prod=false
|
||||
|
||||
cd "$APP_DIR"
|
||||
test "$PWD" = "$APP_DIR"
|
||||
# Do not export .env manually.
|
||||
# Next.js and the migration script load it themselves.
|
||||
|
||||
echo "--- Preparing pnpm ---"
|
||||
sudo corepack enable
|
||||
sudo corepack prepare [email protected] --activate
|
||||
# 4. Generate Prisma client
|
||||
echo "--- Generating Prisma Client ---"
|
||||
pnpm prisma:generate
|
||||
|
||||
echo "--- Installing Locked Dependencies ---"
|
||||
sudo pnpm install --frozen-lockfile --prod=false
|
||||
# 5. Run database migrations
|
||||
echo "--- Running Database Migrations ---"
|
||||
pnpm db:migrate
|
||||
|
||||
echo "--- Generating Prisma Client ---"
|
||||
sudo pnpm prisma:generate
|
||||
# 6. Build the application
|
||||
echo "--- Building Application ---"
|
||||
rm -rf -- "$APP_DIR/.next"
|
||||
pnpm build
|
||||
|
||||
echo "--- Running Database Migrations ---"
|
||||
sudo pnpm db:migrate
|
||||
# 7. Restart and verify service
|
||||
echo "--- Restarting Atom Nexst Service ---"
|
||||
systemctl restart atom-nexst.service
|
||||
systemctl is-active --quiet atom-nexst.service
|
||||
|
||||
echo "--- Building Application ---"
|
||||
sudo rm -rf -- "$APP_DIR/.next"
|
||||
sudo pnpm build
|
||||
|
||||
echo "--- Restarting Atom Nexst Service ---"
|
||||
sudo systemctl restart atom-nexst.service
|
||||
sudo systemctl is-active --quiet atom-nexst.service
|
||||
|
||||
echo "--- Verifying Deployed Revision ---"
|
||||
echo "DEPLOYED_COMMIT=${GITHUB_SHA}"
|
||||
|
||||
echo "--- Deployment Completed Successfully ---"
|
||||
echo "--- Deployment Completed Successfully ---"
|
||||
Reference in new issue
Block a user