diff --git a/composer.json b/composer.json index 505643b..dfa0e5a 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "spatie/laravel-responsecache": "^7.7" }, "require-dev": { - "austinmastlab/deployer-recipes": "^1.0.1", + "austinmastlab/deployer-recipes": "^1.2.0-rc1", "barryvdh/laravel-debugbar": "^3.5", "barryvdh/laravel-ide-helper": "^v3.0.0", "deployer/deployer": "^8.0", diff --git a/composer.lock b/composer.lock index c858d57..3c3f7cd 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "0ec91fb2514b20732786ca22fd5308a9", + "content-hash": "41889d1108bf21510f15dd43073bd51b", "packages": [ { "name": "anourvalar/eloquent-serialize", @@ -10605,16 +10605,16 @@ "packages-dev": [ { "name": "austinmastlab/deployer-recipes", - "version": "v1.1.0", + "version": "v1.2.0-rc1", "source": { "type": "git", "url": "https://github.com/AustinMastLab/deployer-recipes", - "reference": "6b1d741b3911863b6562ff28c7e9354ae688aeba" + "reference": "9622dea28fca2d50f21001ceed0794f342a1a87a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/AustinMastLab/deployer-recipes/zipball/6b1d741b3911863b6562ff28c7e9354ae688aeba", - "reference": "6b1d741b3911863b6562ff28c7e9354ae688aeba", + "url": "https://api.github.com/repos/AustinMastLab/deployer-recipes/zipball/9622dea28fca2d50f21001ceed0794f342a1a87a", + "reference": "9622dea28fca2d50f21001ceed0794f342a1a87a", "shasum": "" }, "require": { @@ -10631,7 +10631,7 @@ ], "type": "library", "description": "Shared Deployer recipes and AWS SSM environment tools for AustinMastLab sites", - "time": "2026-10-11T17:41:30+00:00" + "time": "2026-10-21T16:43:04+00:00" }, { "name": "barryvdh/laravel-debugbar", diff --git a/deploy.php b/deploy.php index 6938253..c39a4a5 100644 --- a/deploy.php +++ b/deploy.php @@ -34,11 +34,15 @@ require 'recipe/laravel.php'; require __DIR__.'/vendor/austinmastlab/deployer-recipes/recipe/ssm-env.php'; +require __DIR__.'/vendor/austinmastlab/deployer-recipes/recipe/ci-artifacts.php'; require 'deploy/custom.php'; // .env is generated from SSM /digitizationacademy/{environment} by env:ssm (austinmastlab/deployer-recipes). set('ssm_app', 'digitizationacademy'); +// supervisor:reload (deployer-recipes) updates only this site's Supervisor group +set('supervisor_groups', ['da']); + // Deployment Configuration set('repository', 'https://github.com/AustinMastLab/DigitizationAcademy.git'); set('base_path', '/data/web'); diff --git a/deploy/custom.php b/deploy/custom.php index 2925759..734bf85 100644 --- a/deploy/custom.php +++ b/deploy/custom.php @@ -81,70 +81,8 @@ desc('Publish the Sweet Alert JavaScript'); task('artisan:alert:publish', artisan('alert:publish --assets --force')); -/** - * Reload Supervisor configuration - * Executes reread and update commands for Supervisor - */ -desc('Reload Supervisor configuration (config-only update)'); -task('supervisor:reload', function () { - run('sudo supervisorctl reread'); - run('sudo supervisorctl update'); -}); - -/* - * ============================================================================= - * CI/CD ARTIFACT DEPLOYMENT - CORE FEATURE - * ============================================================================= - */ - -desc('Download and extract pre-built assets from GitHub Actions'); -task('deploy:ci-artifacts', function () { - // Environment variables automatically provided by GitHub Actions workflow - $githubToken = $_ENV['GITHUB_TOKEN'] ?? getenv('GITHUB_TOKEN') ?? ''; - $githubSha = $_ENV['GITHUB_SHA'] ?? getenv('GITHUB_SHA') ?? ''; - $githubRepo = $_ENV['GITHUB_REPO'] ?? getenv('GITHUB_REPO') ?? 'AustinMastLab/DigitizationAcademy'; - - // Validate required environment variables - if (empty($githubToken) || empty($githubSha)) { - throw new \Exception('GITHUB_TOKEN and GITHUB_SHA environment variables are required.'); - } - - // Artifact naming convention: digitizationacademy-{git-sha} - $artifactName = "digitizationacademy-{$githubSha}"; - writeln("Downloading CI artifact: {$artifactName}"); - - // Step 1: Get artifact download URL from GitHub API - $apiUrl = "https://api.github.com/repos/{$githubRepo}/actions/artifacts"; - $response = runLocally("curl -H 'Authorization: Bearer {$githubToken}' -H 'Accept: application/vnd.github.v3+json' '{$apiUrl}?name={$artifactName}&per_page=1'"); - $artifacts = json_decode($response, true); - - if (empty($artifacts['artifacts'])) { - throw new \Exception("No CI artifact found with name: {$artifactName}"); - } - - $downloadUrl = $artifacts['artifacts'][0]['archive_download_url']; - cd('{{release_or_current_path}}'); - - // Step 2: Download and extract - run("curl -L -H 'Authorization: Bearer {$githubToken}' -H 'Accept: application/vnd.github.v3+json' '{$downloadUrl}' -o artifact.zip"); - run('unzip -o -q artifact.zip'); - - // Step 3: Biospex-style Nesting Correction - $nestLevelCmd = run('find . -type d -name "deployment-package" -printf "%p\\n" | wc -l'); - $nests = (int) trim($nestLevelCmd); - - if ($nests > 0) { - $innermost = run('find . -type d -name "deployment-package" | sort -r | head -1'); - $innermost = trim($innermost); - if (! empty($innermost)) { - run("rsync -av '{$innermost}/' ./"); - run('find . -type d -name "deployment-package" -exec rm -rf {} +'); - } - } - - run('rm -f artifact.zip'); - writeln('✅ CI artifacts deployed successfully (Flat structure ensured)'); -}); +// deploy:ci-artifacts, deploy:verify-structure and supervisor:reload come from +// deployer-recipes/recipe/ci-artifacts.php (required in deploy.php). /* * ============================================================================= @@ -152,15 +90,6 @@ * ============================================================================= */ -desc('Verify flat deployment structure'); -task('deploy:verify-structure', function () { - $nestCheck = run('find {{release_path}} -type d -name "deployment-package" | wc -l'); - if ((int) trim($nestCheck) > 0) { - throw new \Exception("Nesting detected post-deploy: {$nestCheck} dirs. Check CI artifact."); - } - writeln('✅ Deployment structure verified: flat and clean'); -}); - /** * Clear package discovery cache before running composer operations * This prevents conflicts when packages are removed (like Nova)