revert 71e0457e7e
Remote Build and Deploy / deploy (push) Failing after 1s
Remote Build and Deploy / deploy (push) Failing after 1s
revert Update .gitea/workflows/deploy.yaml Signed-off-by: Simo <[email protected]>
This commit is contained in:
1 parent
71e0457e7e
commit
3140cbbbd4
1 file changed
+42
-103
+42
-103
@@ -11,130 +11,69 @@ concurrency:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: shell
|
||||||
timeout-minutes: 30
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check out exact commit
|
- name: Check out pushed commit
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 1
|
fetch-depth: 1
|
||||||
|
|
||||||
- name: Create release archive
|
- name: Deploy AtomCMS
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
set -Eeuo pipefail
|
set -Eeuo pipefail
|
||||||
|
|
||||||
git archive \
|
readonly APP_DIR="/var/www/atom-nexst"
|
||||||
--format=tar.gz \
|
readonly SOURCE_DIR="${GITHUB_WORKSPACE}"
|
||||||
--output=atomcms-release.tar.gz \
|
|
||||||
HEAD
|
|
||||||
|
|
||||||
test -s atomcms-release.tar.gz
|
echo "--- Starting EPIC WEB CONTROL Deployment ---"
|
||||||
sha256sum atomcms-release.tar.gz > atomcms-release.tar.gz.sha256
|
|
||||||
|
|
||||||
- name: Upload release to VPS
|
test -n "$SOURCE_DIR"
|
||||||
uses: appleboy/[email protected]
|
test -d "$SOURCE_DIR/src"
|
||||||
with:
|
test -f "$SOURCE_DIR/package.json"
|
||||||
host: "172.20.2.1"
|
test -f "$SOURCE_DIR/pnpm-lock.yaml"
|
||||||
username: "root"
|
|
||||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
||||||
port: 22
|
|
||||||
source: "atomcms-release.tar.gz,atomcms-release.tar.gz.sha256"
|
|
||||||
target: "/tmp"
|
|
||||||
overwrite: true
|
|
||||||
timeout: 120s
|
|
||||||
command_timeout: 10m
|
|
||||||
|
|
||||||
- name: Deploy through SSH
|
test -d "$APP_DIR"
|
||||||
uses: appleboy/[email protected]
|
test -f "$APP_DIR/.env"
|
||||||
with:
|
test "$APP_DIR" = "/var/www/atom-nexst"
|
||||||
host: "172.20.2.1"
|
|
||||||
username: "root"
|
|
||||||
key: ${{ secrets.SSH_PRIVATE_KEY }}
|
|
||||||
port: 22
|
|
||||||
timeout: 120s
|
|
||||||
command_timeout: 25m
|
|
||||||
script: |
|
|
||||||
set -Eeuo pipefail
|
|
||||||
|
|
||||||
readonly APP_DIR="/var/www/atom-nexst"
|
echo "--- Synchronizing Application Files ---"
|
||||||
readonly RELEASE="/tmp/atomcms-release.tar.gz"
|
|
||||||
readonly CHECKSUM="/tmp/atomcms-release.tar.gz.sha256"
|
|
||||||
readonly BACKUP_DIR="/var/backups/atom-nexst"
|
|
||||||
readonly TIMESTAMP="$(date +%Y%m%d-%H%M%S)"
|
|
||||||
|
|
||||||
failure() {
|
sudo rsync -a --delete \
|
||||||
local exit_code=$?
|
--exclude=".git/" \
|
||||||
echo "--- DEPLOYMENT FAILED with code ${exit_code} ---"
|
--exclude=".env" \
|
||||||
systemctl status atom-nexst.service --no-pager || true
|
--exclude=".next/" \
|
||||||
exit "$exit_code"
|
--exclude="node_modules/" \
|
||||||
}
|
--exclude="storage/" \
|
||||||
|
--exclude="docs/" \
|
||||||
|
"$SOURCE_DIR/" "$APP_DIR/"
|
||||||
|
|
||||||
trap failure ERR
|
cd "$APP_DIR"
|
||||||
|
test "$PWD" = "$APP_DIR"
|
||||||
|
|
||||||
echo "--- Starting EPIC WEB CONTROL Deployment ---"
|
echo "--- Preparing pnpm ---"
|
||||||
|
sudo corepack enable
|
||||||
|
sudo corepack prepare [email protected] --activate
|
||||||
|
|
||||||
test "$APP_DIR" = "/var/www/atom-nexst"
|
echo "--- Installing Locked Dependencies ---"
|
||||||
test -d "$APP_DIR"
|
sudo pnpm install --frozen-lockfile --prod=false
|
||||||
test -f "$APP_DIR/.env"
|
|
||||||
test -s "$RELEASE"
|
|
||||||
test -s "$CHECKSUM"
|
|
||||||
|
|
||||||
cd /tmp
|
echo "--- Generating Prisma Client ---"
|
||||||
sha256sum --check "$CHECKSUM"
|
sudo pnpm prisma:generate
|
||||||
|
|
||||||
mkdir -p "$BACKUP_DIR"
|
echo "--- Running Database Migrations ---"
|
||||||
|
sudo pnpm db:migrate
|
||||||
|
|
||||||
echo "--- Creating rollback backup ---"
|
echo "--- Building Application ---"
|
||||||
tar \
|
sudo rm -rf -- "$APP_DIR/.next"
|
||||||
--exclude=".next" \
|
sudo pnpm build
|
||||||
--exclude="node_modules" \
|
|
||||||
--exclude="storage" \
|
|
||||||
--exclude=".env" \
|
|
||||||
-czf "$BACKUP_DIR/release-$TIMESTAMP.tar.gz" \
|
|
||||||
-C "$APP_DIR" .
|
|
||||||
|
|
||||||
cd "$APP_DIR"
|
echo "--- Restarting Atom Nexst Service ---"
|
||||||
test "$PWD" = "$APP_DIR"
|
sudo systemctl restart atom-nexst.service
|
||||||
|
sudo systemctl is-active --quiet atom-nexst.service
|
||||||
|
|
||||||
echo "--- Replacing tracked application files ---"
|
echo "--- Verifying Deployed Revision ---"
|
||||||
|
echo "DEPLOYED_COMMIT=${GITHUB_SHA}"
|
||||||
|
|
||||||
# These directories come entirely from Git.
|
echo "--- Deployment Completed Successfully ---"
|
||||||
# Persistent .env, storage and node_modules remain untouched.
|
|
||||||
rm -rf -- src public prisma scripts .gitea
|
|
||||||
|
|
||||||
tar -xzf "$RELEASE" -C "$APP_DIR"
|
|
||||||
|
|
||||||
rm -f -- "$RELEASE" "$CHECKSUM"
|
|
||||||
|
|
||||||
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 -- "$APP_DIR/.next"
|
|
||||||
pnpm build
|
|
||||||
|
|
||||||
echo "--- Restarting service ---"
|
|
||||||
systemctl restart atom-nexst.service
|
|
||||||
systemctl is-active --quiet atom-nexst.service
|
|
||||||
|
|
||||||
echo "--- Cleaning old backups ---"
|
|
||||||
find "$BACKUP_DIR" \
|
|
||||||
-maxdepth 1 \
|
|
||||||
-type f \
|
|
||||||
-name "release-*.tar.gz" \
|
|
||||||
-mtime +7 \
|
|
||||||
-delete
|
|
||||||
|
|
||||||
echo "--- Deployment Completed Successfully ---"
|
|
||||||
Reference in new issue
Block a user