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