88 lines
2.4 KiB
YAML
88 lines
2.4 KiB
YAML
name: Remote Build and Deploy
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- 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]
|
|
with:
|
|
host: "172.20.2.1"
|
|
username: "root"
|
|
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
port: 22
|
|
command_timeout: 20m
|
|
script: |
|
|
set -Eeuo pipefail
|
|
|
|
readonly APP_DIR="/var/www/atom-nexst"
|
|
readonly RELEASE="/tmp/atomcms-release.tar.gz"
|
|
|
|
echo "--- Starting EPIC WEB CONTROL Deployment ---"
|
|
|
|
test -d "$APP_DIR"
|
|
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
|
|
|
|
echo "--- Running Database Migrations ---"
|
|
pnpm db:migrate
|
|
|
|
echo "--- Building Application ---"
|
|
rm -rf -- .next
|
|
pnpm build
|
|
|
|
echo "--- Restarting Atom Nexst Service ---"
|
|
systemctl restart atom-nexst.service
|
|
systemctl is-active --quiet atom-nexst.service
|
|
|
|
echo "--- Deployment Completed Successfully ---" |