From 0699fbbdd641a780c518c4bf016ebf22216519d8 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 16 Jul 2026 00:48:17 -0400 Subject: [PATCH] add deploy creation --- .gitea/workflows/deploy.yml | 11 +++---- DEPLOYMENT_FILES.md | 34 ++++++++++++++++++++++ scripts/build-deploy-artifact.sh | 49 ++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 7 deletions(-) create mode 100644 DEPLOYMENT_FILES.md create mode 100755 scripts/build-deploy-artifact.sh diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 0c3638d..1ced115 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -37,6 +37,9 @@ jobs: - name: Install production dependencies run: composer install --no-dev --no-interaction --prefer-dist --no-progress --optimize-autoloader + - name: Create deployment artifact + run: bash scripts/build-deploy-artifact.sh + - name: Configure SSH run: | test -n "${DEPLOY_HOST}" @@ -61,19 +64,13 @@ jobs: rsync -az --delete \ -e "ssh -i ~/.ssh/deploy_key -p ${SSH_PORT}" \ - --exclude '.git/' \ - --exclude '.gitea/' \ --exclude '.env' \ - --exclude 'env' \ - --exclude 'env.*' \ --exclude 'writable/cache/***' \ --exclude 'writable/logs/***' \ --exclude 'writable/session/***' \ --exclude 'writable/uploads/***' \ --exclude 'writable/debugbar/***' \ - --exclude 'tests/' \ - --exclude 'phpunit.xml*' \ - ./ "${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}/" + build/deploy/ "${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}/" - name: Finalize deployment run: | diff --git a/DEPLOYMENT_FILES.md b/DEPLOYMENT_FILES.md new file mode 100644 index 0000000..322813f --- /dev/null +++ b/DEPLOYMENT_FILES.md @@ -0,0 +1,34 @@ +# Deployment Files + +The hosting deployment is built by `scripts/build-deploy-artifact.sh` into `build/deploy/`. + +Included: + +- `app/` +- `bootstrap/` +- `public/` +- `routes/` +- `vendor/` +- `composer.json` +- `composer.lock` +- `spark` +- `preload.php` +- `writable/.htaccess` +- `writable/index.html` +- `writable/.gitkeep` +- `writable/*/.gitkeep` +- `writable/tcpdf_fonts/` + +Excluded: + +- `.git/` +- `.gitea/` +- `.env` and local env backups +- `tests/` +- `Database_Dump/` +- `build/` except the generated deploy artifact during CI +- documentation/planning files +- local scripts that are not needed at runtime +- runtime cache, logs, sessions, uploads, and generated reports + +The server keeps its own `.env` and runtime `writable/` contents. The deploy job syncs from `build/deploy/` and excludes mutable writable subdirectories so production data is not overwritten. diff --git a/scripts/build-deploy-artifact.sh b/scripts/build-deploy-artifact.sh new file mode 100755 index 0000000..e77b47e --- /dev/null +++ b/scripts/build-deploy-artifact.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +DEPLOY_DIR="${1:-"${ROOT_DIR}/build/deploy"}" + +rm -rf "${DEPLOY_DIR}" +mkdir -p "${DEPLOY_DIR}" + +copy_path() { + local source="$1" + + if [ -e "${ROOT_DIR}/${source}" ]; then + mkdir -p "${DEPLOY_DIR}/$(dirname "${source}")" + cp -a "${ROOT_DIR}/${source}" "${DEPLOY_DIR}/${source}" + fi +} + +# CodeIgniter application/runtime entry points. +copy_path app +copy_path bootstrap +copy_path public +copy_path routes +copy_path vendor +copy_path composer.json +copy_path composer.lock +copy_path spark +copy_path preload.php + +# Writable should exist on the server, but deploy only safe skeleton files. +mkdir -p \ + "${DEPLOY_DIR}/writable/cache" \ + "${DEPLOY_DIR}/writable/debugbar" \ + "${DEPLOY_DIR}/writable/logs" \ + "${DEPLOY_DIR}/writable/reports" \ + "${DEPLOY_DIR}/writable/session" \ + "${DEPLOY_DIR}/writable/uploads" + +copy_path writable/.htaccess +copy_path writable/index.html +copy_path writable/.gitkeep +copy_path writable/cache/.gitkeep +copy_path writable/debugbar/.gitkeep +copy_path writable/logs/.gitkeep +copy_path writable/session/.gitkeep +copy_path writable/uploads/.gitkeep +copy_path writable/tcpdf_fonts + +find "${DEPLOY_DIR}" -name '.DS_Store' -delete