Skip to content

Commit ff41894

Browse files
committed
Merge branch 'main' into development
2 parents fff5e7e + d2272f0 commit ff41894

44 files changed

Lines changed: 790 additions & 681 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/deploy.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ jobs:
3333
# Create release when pushing to main
3434
create-release:
3535
runs-on: ubuntu-latest
36+
permissions:
37+
contents: write
3638
if: "github.ref == 'refs/heads/main' && !contains(github.event.head_commit.message, '[skip deploy]') && !contains(github.event.head_commit.message, '[no deploy]')"
3739
outputs:
3840
release-tag: ${{ steps.create_release.outputs.tag_name }}
@@ -159,8 +161,6 @@ jobs:
159161
with:
160162
php-version: '8.3'
161163
extensions: mbstring, xml, bcmath, ctype, json, tokenizer, pdo, pdo_mysql
162-
- name: Setup Composer authentication for Laravel Nova
163-
run: composer config http-basic.nova.laravel.com ${{ secrets.NOVA_USERNAME }} ${{ secrets.NOVA_PASSWORD }}
164164
- name: Cache Composer packages
165165
id: composer-cache
166166
uses: actions/cache@v3
@@ -260,8 +260,6 @@ jobs:
260260
with:
261261
php-version: '8.3'
262262
extensions: mbstring, xml, bcmath, ctype, json, tokenizer, pdo, pdo_mysql
263-
- name: Setup Composer authentication for Laravel Nova
264-
run: composer config http-basic.nova.laravel.com ${{ secrets.NOVA_USERNAME }} ${{ secrets.NOVA_PASSWORD }}
265263
- name: Cache Composer packages
266264
id: composer-cache
267265
uses: actions/cache@v3

COMMIT_CONVENTIONS.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ Version numbers follow the format `MAJOR.MINOR.PATCH` (e.g., `1.2.3`).
1010

1111
## How It Works
1212

13-
1. **Development Branch**: Push to `development` → Automatically deploys to development environment
13+
1. **Development Branch**: Push to `development` → Automatically deploys to development environment (Host: `3.138.217.206`)
14+
- Operates using `dev-` prefixed SQS queues.
1415
2. **Main Branch**: Push to `main` → Creates GitHub release with auto-incremented version → Automatically deploys to
15-
production
16+
production (Host: `3.142.169.134`)
17+
- Operates using `prod-` prefixed SQS queues.
1618
3. **Version Control**: Commit messages determine which part of the version number gets incremented
1719

1820
## Version Bump Rules

DEPLOYMENT_SETUP.md

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@ If you need to test deployments locally:
3434
4. **Deploys using deployphp** with environment variables for token access
3535

3636
### Deployment Process (`deploy.php` + `deploy/custom.php`)
37-
1. **Downloads CI artifacts** using GitHub API
38-
2. **Extracts and deploys** built assets without server-side building
39-
3. **Checks queue status** before restarting to prevent job interruption
40-
4. **Cleans up** temporary files and node_modules automatically
37+
1. **PHP 8.3 Environment**: The deployment now runs on PHP 8.3.
38+
2. **Downloads CI artifacts** using GitHub API: This replaces server-side building, so `npm` or `yarn` are no longer required on the server.
39+
3. **Dynamic SQS Queues**: Queue names are now environment-prefixed (`prod-`, `dev-`, or `loc-`) as defined in `config/services.php`.
40+
4. **Filament & OpCache**: Automated tasks now handle Filament asset optimization and OpCache resets during deployment.
41+
5. **Checks queue status** before restarting to prevent job interruption
42+
6. **Cleans up** temporary files and node_modules automatically
4143

4244
## Key Features
4345

@@ -47,20 +49,14 @@ If you need to test deployments locally:
4749
- Faster deployments with reduced server resource usage
4850

4951
### ✅ Queue-Safe Deployments
50-
- `queue:count` command checks Beanstalkd queue status
51-
- Deployment pauses queue restart if jobs are running
52-
- Prevents interruption of long-running tasks (e.g., CSV processing)
53-
54-
### ✅ Automatic Cleanup
55-
- `node_modules` removed automatically via `clear_paths`
56-
- Temporary artifact files cleaned up after deployment
57-
- No manual intervention required
52+
- `queue:count` command checks status before restarting.
53+
- **Dynamic Prefixing**: SQS queues are dynamically named based on the environment (e.g., `prod-batch-trigger`).
5854

5955
## Queue Names Configuration
60-
The deployment checks these queues by default:
61-
- `export`
62-
- `geolocate`
63-
- `pusher_classification`
56+
The deployment checks these queues by default. Note that names are now derived from the `APP_ENV` prefix:
57+
- `{{prefix}}-export`
58+
- `{{prefix}}-geolocate`
59+
- `{{prefix}}-pusher_classification`
6460

6561
To modify queue names, edit the `$queues` array in `deploy/custom.php`:
6662
```php

app/Console/Commands/AppUpdateQueriesCommand.php

Lines changed: 1 addition & 208 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@
2020

2121
namespace App\Console\Commands;
2222

23-
use App\Jobs\PusherTranscriptionJob;
2423
use Illuminate\Console\Command;
25-
use Illuminate\Support\Facades\DB;
26-
use Illuminate\Support\Facades\Storage;
2724

2825
/**
2926
* Class UpdateQueries
@@ -51,209 +48,5 @@ public function __construct()
5148
/**
5249
* Fire command
5350
*/
54-
public function handle()
55-
{
56-
$operation = $this->argument('operation');
57-
58-
switch ($operation) {
59-
case 'create-directories':
60-
$this->createS3Directories();
61-
break;
62-
63-
case 'move-files':
64-
$this->moveS3DirectoryFiles();
65-
break;
66-
67-
case 'update-paths':
68-
$this->updateDatabasePaths();
69-
break;
70-
case 'process-classifications':
71-
$this->processClassifications();
72-
break;
73-
74-
default:
75-
$this->createS3Directories();
76-
$this->moveS3DirectoryFiles();
77-
$this->updateDatabasePaths();
78-
$this->processClassifications();
79-
}
80-
}
81-
82-
/**
83-
* Create required directories in S3 bucket
84-
*/
85-
protected function createS3Directories(): void
86-
{
87-
$directories = [
88-
config('config.uploads.site-assets'),
89-
config('config.uploads.project-assets'),
90-
];
91-
92-
foreach ($directories as $directory) {
93-
try {
94-
if (! Storage::disk('s3')->exists($directory)) {
95-
Storage::disk('s3')->makeDirectory($directory);
96-
}
97-
} catch (\Exception $e) {
98-
$this->error("Failed to create directory {$directory}: ".$e->getMessage());
99-
}
100-
}
101-
}
102-
103-
/**
104-
* Move files between S3 directories using AWS CLI for optimal performance
105-
*/
106-
protected function moveS3DirectoryFiles(): void
107-
{
108-
$bucket = config('filesystems.disks.s3.bucket');
109-
$region = config('filesystems.disks.s3.region');
110-
111-
$migrations = [
112-
[
113-
'from' => config('config.uploads.project_resources_downloads'),
114-
'to' => config('config.uploads.project-assets'),
115-
'name' => 'project resources to project assets',
116-
],
117-
[
118-
'from' => config('config.uploads.resources'),
119-
'to' => config('config.uploads.site-assets'),
120-
'name' => 'resources to site assets',
121-
],
122-
];
123-
124-
foreach ($migrations as $migration) {
125-
$this->migrateS3Directory($bucket, $region, $migration['from'], $migration['to'], $migration['name']);
126-
}
127-
}
128-
129-
/**
130-
* Migrate files from one S3 directory to another using AWS CLI
131-
*/
132-
protected function migrateS3Directory(string $bucket, string $region, string $fromDir, string $toDir, string $description): void
133-
{
134-
// Check if source directory has files
135-
$listCommand = sprintf(
136-
'aws s3 ls s3://%s/%s/ --region %s --recursive',
137-
escapeshellarg($bucket),
138-
escapeshellarg($fromDir),
139-
escapeshellarg($region)
140-
);
141-
142-
$output = [];
143-
$returnCode = 0;
144-
exec($listCommand.' 2>/dev/null', $output, $returnCode);
145-
146-
if (empty($output)) {
147-
return;
148-
}
149-
150-
$fileCount = count($output);
151-
152-
// Get initial count of destination directory
153-
$destListCommand = sprintf(
154-
'aws s3 ls s3://%s/%s/ --region %s --recursive',
155-
escapeshellarg($bucket),
156-
escapeshellarg($toDir),
157-
escapeshellarg($region)
158-
);
159-
160-
$destInitialOutput = [];
161-
$destInitialReturnCode = 0;
162-
exec($destListCommand.' 2>/dev/null', $destInitialOutput, $destInitialReturnCode);
163-
164-
$initialDestFileCount = count($destInitialOutput);
165-
$expectedFinalCount = $initialDestFileCount + $fileCount;
166-
167-
// Copy files to new directory
168-
$copyCommand = sprintf(
169-
'aws s3 cp s3://%s/%s/ s3://%s/%s/ --region %s --recursive',
170-
escapeshellarg($bucket),
171-
escapeshellarg($fromDir),
172-
escapeshellarg($bucket),
173-
escapeshellarg($toDir),
174-
escapeshellarg($region)
175-
);
176-
177-
$copyOutput = [];
178-
$copyReturnCode = 0;
179-
exec($copyCommand.' 2>&1', $copyOutput, $copyReturnCode);
180-
181-
if ($copyReturnCode !== 0) {
182-
$this->error(' Failed to copy files: '.implode("\n", $copyOutput));
183-
184-
return;
185-
}
186-
187-
// Verify copy operation by listing destination directory
188-
$verifyOutput = [];
189-
$verifyReturnCode = 0;
190-
exec($destListCommand.' 2>/dev/null', $verifyOutput, $verifyReturnCode);
191-
192-
$actualFinalCount = count($verifyOutput);
193-
194-
if ($actualFinalCount !== $expectedFinalCount) {
195-
$this->error(" Verification failed: Expected {$expectedFinalCount} files, found {$actualFinalCount}");
196-
197-
return;
198-
}
199-
}
200-
201-
/**
202-
* Update database paths for moved files
203-
*/
204-
protected function updateDatabasePaths(): void
205-
{
206-
// Update ProjectAsset paths from project-resources/downloads to project-assets
207-
$oldProjectPath = config('config.uploads.project_resources_downloads');
208-
$newProjectPath = config('config.uploads.project-assets');
209-
210-
$projectAssetUpdates = DB::table('project_assets')
211-
->where('download_path', 'LIKE', $oldProjectPath.'/%')
212-
->get();
213-
214-
if ($projectAssetUpdates->isNotEmpty()) {
215-
foreach ($projectAssetUpdates as $asset) {
216-
$newPath = str_replace($oldProjectPath, $newProjectPath, $asset->download_path);
217-
218-
DB::table('project_assets')
219-
->where('id', $asset->id)
220-
->update(['download_path' => $newPath]);
221-
}
222-
}
223-
224-
// Update SiteAsset paths from resources to site-assets
225-
$oldSitePath = config('config.uploads.resources');
226-
$newSitePath = config('config.uploads.site-assets');
227-
228-
$siteAssetUpdates = DB::table('site_assets')
229-
->where('download_path', 'LIKE', $oldSitePath.'/%')
230-
->get();
231-
232-
if ($siteAssetUpdates->isNotEmpty()) {
233-
foreach ($siteAssetUpdates as $asset) {
234-
$newPath = str_replace($oldSitePath, $newSitePath, $asset->download_path);
235-
236-
DB::table('site_assets')
237-
->where('id', $asset->id)
238-
->update(['download_path' => $newPath]);
239-
}
240-
}
241-
}
242-
243-
public function processClassifications(): void
244-
{
245-
DB::table('pusher_classifications')->orderBy('id')->chunkById(100, function ($chunk) {
246-
$ids = [];
247-
foreach ($chunk as $row) {
248-
$data = json_decode($row->data, true);
249-
if ($data && is_array($data)) {
250-
PusherTranscriptionJob::dispatch($data);
251-
$ids[] = $row->id;
252-
}
253-
}
254-
if ($ids) {
255-
DB::table('pusher_classifications')->whereIn('id', $ids)->delete();
256-
}
257-
}, 'id');
258-
}
51+
public function handle() {}
25952
}

app/Http/Controllers/Front/SiteAssetController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ public function index(SiteAsset $siteAsset): \Illuminate\Contracts\View\View
4848
*/
4949
public function show(SiteAsset $siteAsset): RedirectResponse|StreamedResponse
5050
{
51-
if (! $siteAsset->document->exists() || ! file_exists(public_path('storage'.$siteAsset->document->path()))) {
51+
if (empty($siteAsset->download_path) || ! Storage::disk('s3')->exists($siteAsset->download_path)) {
5252

5353
return Redirect::route('front.site-assets.index')
5454
->with('danger', t('File cannot be found.'));
5555
}
5656

57-
return Storage::download('public/'.$siteAsset->document->path());
57+
return Storage::disk('s3')->download($siteAsset->download_path);
5858
}
5959
}

app/Http/Middleware/EncryptCookies.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ class EncryptCookies extends Middleware
3030
* @var array
3131
*/
3232
protected $except = [
33-
//
33+
'app_flash',
3434
];
3535
}

0 commit comments

Comments
 (0)