Update .gitea/workflows/deploy.yaml
Local Build and Deploy / deploy (push) Successful in 41s

This commit is contained in:
Simo committed 2026-07-12 13:48:13 +02:00
1 parent 69ca4b035b
commit 9b1bc2fd09
1 file changed
+22 -76
+22 -76
View File
@@ -5,96 +5,42 @@ on:
branches:
- main
concurrency:
group: atom-nexst-production
cancel-in-progress: false
jobs:
deploy:
runs-on: shell
timeout-minutes: 20
steps:
- name: Run Deploy Scripts Locally
shell: bash
run: |
set -Eeuo pipefail
set -e
echo "--- EPIC WEB CONTROL: Starting Auto-Cleanup & Deploy ---"
APP_DIR="/var/www/atom-nexst"
SERVICE_NAME="atom-nexst.service"
REPOSITORY="/docker/gitea/gitea/git/repositories/remco/epicnext-cms.git"
LOCK_FILE="/tmp/atom-nexst-deploy.lock"
HEALTH_URL="http://127.0.0.1:3000/api/health"
# 1. Clean up unused build images safely
docker image prune -f
echo "--- EPIC WEB CONTROL: Starting Deploy ---"
# 2. Navigate to your website directory
cd /var/www/atom-nexst/
exec 9>"$LOCK_FILE"
# Point Git directly to the local Gitea folder path
git remote set-url origin /docker/gitea/gitea/git/repositories/remco/epicnext-cms.git/
if ! flock -n 9; then
echo "ERROR: Another deployment is already running."
exit 1
fi
if [ ! -d "$APP_DIR/.git" ]; then
echo "ERROR: $APP_DIR is not a Git repository."
exit 1
fi
cd "$APP_DIR"
git remote set-url origin "$REPOSITORY"
git fetch origin main --prune
# 3. Fetch and update code as root to bypass folder permission blocks
git fetch origin --prune
git reset --hard origin/main
test -f package.json
test -f pnpm-lock.yaml
# Fix ownership: Ensure www-data owns the files for the web server
sudo chown -R www-data:www-data /var/www/atom-nexst/
corepack enable
corepack prepare [email protected] --activate
# 4. Configure pnpm to automatically approve build scripts for dependencies
pnpm config set trusted-dependencies @parcel/watcher,@swc/core,sharp
sudo chown -R www-data:www-data "$APP_DIR"
# Install dependencies, run migrations, and build the application
pnpm install --frozen-lockfile
pnpm db:migrate
pnpm prisma generate
pnpm build
sudo -u www-data env HOME=/var/www \
pnpm install --frozen-lockfile
# 5. Restart the application service
sudo systemctl restart atom-nexst.service
sudo -u www-data env HOME=/var/www \
pnpm prisma:generate
sudo -u www-data env HOME=/var/www \
pnpm typecheck
sudo -u www-data env HOME=/var/www \
pnpm test
sudo -u www-data env HOME=/var/www \
pnpm build
sudo -u www-data env HOME=/var/www \
pnpm db:migrate
sudo systemctl restart "$SERVICE_NAME"
if ! sudo systemctl is-active --quiet "$SERVICE_NAME"; then
echo "ERROR: $SERVICE_NAME failed to start."
sudo journalctl -u "$SERVICE_NAME" -n 100 --no-pager
exit 1
fi
for attempt in $(seq 1 15); do
if curl \
--fail \
--silent \
--show-error \
--max-time 5 \
"$HEALTH_URL" >/dev/null; then
echo "--- Deployment successfully completed ---"
exit 0
fi
echo "Waiting for application startup ($attempt/15)..."
sleep 2
done
echo "ERROR: Application health check failed."
sudo journalctl -u "$SERVICE_NAME" -n 100 --no-pager
exit 1
echo "--- Deployment successfully completed ---"