Skip to content

Commit ad8e971

Browse files
committed
merge develop
2 parents b1e9bf2 + 2b62fa3 commit ad8e971

File tree

717 files changed

+110775
-33391
lines changed

Some content is hidden

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

717 files changed

+110775
-33391
lines changed

.github/workflows/deploy.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches:
66
- main
77
- develop
8+
- feature/vapor-env-updates
89
workflow_dispatch:
910
inputs:
1011
environment:
@@ -60,11 +61,14 @@ jobs:
6061
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
6162
echo "VAPOR_ENV=${{ github.event.inputs.environment }}" >> "$GITHUB_ENV"
6263
echo "TEST_MODE=${{ github.event.inputs.test_mode }}" >> "$GITHUB_ENV"
64+
elif [[ "${{ github.ref_name }}" == "main" ]]; then
65+
echo "VAPOR_ENV=production" >> "$GITHUB_ENV"
66+
echo "TEST_MODE=false" >> "$GITHUB_ENV"
6367
elif [[ "${{ github.ref_name }}" == "develop" ]]; then
6468
echo "VAPOR_ENV=staging" >> "$GITHUB_ENV"
6569
echo "TEST_MODE=false" >> "$GITHUB_ENV"
6670
else
67-
echo "VAPOR_ENV=production" >> "$GITHUB_ENV"
71+
echo "VAPOR_ENV=staging" >> "$GITHUB_ENV"
6872
echo "TEST_MODE=false" >> "$GITHUB_ENV"
6973
fi
7074
@@ -73,6 +77,21 @@ jobs:
7377
echo "🚀 Deploying to Vapor environment: ${{ env.VAPOR_ENV }}"
7478
echo "🧪 Test mode: ${{ env.TEST_MODE }}"
7579
80+
- name: Configure AWS Credentials
81+
if: env.TEST_MODE != 'true'
82+
uses: aws-actions/configure-aws-credentials@v4
83+
with:
84+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
85+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_ID }}
86+
aws-region: eu-west-1
87+
88+
- name: Download Encrypted Environment File from S3
89+
if: env.TEST_MODE != 'true'
90+
working-directory: ./backend
91+
run: |
92+
aws s3 cp s3://hi.events-env-secrets/.env.${{ env.VAPOR_ENV }}.encrypted .env.${{ env.VAPOR_ENV }}.encrypted
93+
echo "✅ Downloaded .env.${{ env.VAPOR_ENV }}.encrypted from S3"
94+
7695
- name: Validate Deployment Configuration
7796
working-directory: ./backend
7897
run: |
@@ -83,6 +102,7 @@ jobs:
83102
fi
84103
85104
- name: Deploy to Vapor
105+
if: env.TEST_MODE != 'true'
86106
working-directory: ./backend
87107
run: vapor deploy ${{ env.VAPOR_ENV }}
88108
env:
@@ -105,11 +125,14 @@ jobs:
105125
echo "DO_APP_ID=${{ secrets.DIGITALOCEAN_PRODUCTION_APP_ID }}" >> "$GITHUB_ENV"
106126
fi
107127
echo "TEST_MODE=${{ github.event.inputs.test_mode }}" >> "$GITHUB_ENV"
128+
elif [[ "${{ github.ref_name }}" == "main" ]]; then
129+
echo "DO_APP_ID=${{ secrets.DIGITALOCEAN_PRODUCTION_APP_ID }}" >> "$GITHUB_ENV"
130+
echo "TEST_MODE=false" >> "$GITHUB_ENV"
108131
elif [[ "${{ github.ref_name }}" == "develop" ]]; then
109132
echo "DO_APP_ID=${{ secrets.DIGITALOCEAN_STAGING_APP_ID }}" >> "$GITHUB_ENV"
110133
echo "TEST_MODE=false" >> "$GITHUB_ENV"
111134
else
112-
echo "DO_APP_ID=${{ secrets.DIGITALOCEAN_PRODUCTION_APP_ID }}" >> "$GITHUB_ENV"
135+
echo "DO_APP_ID=${{ secrets.DIGITALOCEAN_STAGING_APP_ID }}" >> "$GITHUB_ENV"
113136
echo "TEST_MODE=false" >> "$GITHUB_ENV"
114137
fi
115138

.github/workflows/post-release-push-images.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ jobs:
99
push_to_registry:
1010
name: Push Docker images to Docker Hub
1111
runs-on: ubuntu-latest
12+
1213
steps:
1314
- name: Check out the repo
1415
uses: actions/checkout@v4
@@ -28,6 +29,9 @@ jobs:
2829
uses: docker/metadata-action@v3
2930
with:
3031
images: daveearley/hi.events-all-in-one
32+
tags: |
33+
type=ref,event=tag
34+
type=raw,value=latest,enable=${{ github.event.release.prerelease == false }}
3135
3236
- name: Build and push All-in-one Docker image
3337
uses: docker/build-push-action@v3
@@ -44,6 +48,9 @@ jobs:
4448
uses: docker/metadata-action@v3
4549
with:
4650
images: daveearley/hi.events-backend
51+
tags: |
52+
type=ref,event=tag
53+
type=raw,value=latest,enable=${{ github.event.release.prerelease == false }}
4754
4855
- name: Build and push Backend Docker image
4956
uses: docker/build-push-action@v3
@@ -60,6 +67,9 @@ jobs:
6067
uses: docker/metadata-action@v3
6168
with:
6269
images: daveearley/hi.events-frontend
70+
tags: |
71+
type=ref,event=tag
72+
type=raw,value=latest,enable=${{ github.event.release.prerelease == false }}
6373
6474
- name: Build and push Frontend Docker image
6575
uses: docker/build-push-action@v3

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
/.idea/**
66
frontend/.env
77
backend/.env
8+
docker/all-in-one/.env
89
todo.md
910
CLAUDE.md
1011
/prompts/**

Dockerfile.all-in-one

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:alpine AS node-frontend
1+
FROM node:22-alpine AS node-frontend
22

33
WORKDIR /app/frontend
44

backend/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
/vendor
88
.env
99
.env.backup
10+
.env.production.*
11+
.env.staging.*
1012
.env.production
1113
.env.staging
1214
.phpunit.result.cache

backend/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ RUN echo "" >> /usr/local/etc/php-fpm.d/docker-php-serversideup-pool.conf && \
99
echo "user = www-data" >> /usr/local/etc/php-fpm.d/docker-php-serversideup-pool.conf && \
1010
echo "group = www-data" >> /usr/local/etc/php-fpm.d/docker-php-serversideup-pool.conf
1111

12-
RUN install-php-extensions intl
12+
RUN install-php-extensions intl imagick
1313

1414
COPY --chown=www-data:www-data . .
1515

backend/Dockerfile.dev

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ COPY --chown=www-data:www-data . /var/www/html
1212

1313
# Switch to root user to install PHP extensions
1414
USER root
15-
RUN install-php-extensions intl
15+
RUN install-php-extensions intl imagick
1616
USER www-data
1717

1818
RUN chmod -R 755 /var/www/html/storage \
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?php
2+
3+
namespace HiEvents\Console\Commands;
4+
5+
use Exception;
6+
use HiEvents\DomainObjects\Enums\Role;
7+
use HiEvents\Repository\Interfaces\AccountUserRepositoryInterface;
8+
use HiEvents\Repository\Interfaces\UserRepositoryInterface;
9+
use Illuminate\Console\Command;
10+
use Psr\Log\LoggerInterface;
11+
12+
class AssignSuperAdminCommand extends Command
13+
{
14+
protected $signature = 'user:make-superadmin {userId : The ID of the user to make a superadmin}';
15+
16+
protected $description = 'Assign SUPERADMIN role to a user. WARNING: This grants complete system access.';
17+
18+
public function __construct(
19+
private readonly UserRepositoryInterface $userRepository,
20+
private readonly AccountUserRepositoryInterface $accountUserRepository,
21+
private readonly LoggerInterface $logger,
22+
)
23+
{
24+
parent::__construct();
25+
}
26+
27+
public function handle(): int
28+
{
29+
$userId = $this->argument('userId');
30+
31+
$this->warn('⚠️ WARNING: This command will grant COMPLETE SYSTEM ACCESS to the user.');
32+
$this->warn('⚠️ SUPERADMIN users have unrestricted access to all accounts and data.');
33+
$this->newLine();
34+
35+
if (!$this->confirm('Are you sure you want to proceed?', false)) {
36+
$this->info('Operation cancelled.');
37+
return self::FAILURE;
38+
}
39+
40+
try {
41+
$user = $this->userRepository->findById((int)$userId);
42+
} catch (Exception $exception) {
43+
$this->error("Error finding user with ID: $userId" . " Message: " . $exception->getMessage());
44+
return self::FAILURE;
45+
}
46+
47+
$this->info("Found user: {$user->getFullName()} ({$user->getEmail()})");
48+
$this->newLine();
49+
50+
if (!$this->confirm('Confirm assigning SUPERADMIN role to this user?', false)) {
51+
$this->info('Operation cancelled.');
52+
return self::FAILURE;
53+
}
54+
55+
$accountUsers = $this->accountUserRepository->findWhere([
56+
'user_id' => $userId,
57+
]);
58+
59+
if ($accountUsers->isEmpty()) {
60+
$this->error('User is not associated with any accounts.');
61+
return self::FAILURE;
62+
}
63+
64+
$updatedCount = 0;
65+
foreach ($accountUsers as $accountUser) {
66+
if ($accountUser->getRole() === Role::SUPERADMIN->name) {
67+
$this->comment("User already has SUPERADMIN role for account ID: {$accountUser->getAccountId()}");
68+
continue;
69+
}
70+
71+
$this->accountUserRepository->updateWhere(
72+
attributes: [
73+
'role' => Role::SUPERADMIN->name,
74+
],
75+
where: [
76+
'id' => $accountUser->getId(),
77+
]
78+
);
79+
80+
$updatedCount++;
81+
82+
$this->logger->critical('SUPERADMIN role assigned via console command', [
83+
'user_id' => $userId,
84+
'user_email' => $user->getEmail(),
85+
'account_id' => $accountUser->getAccountId(),
86+
'previous_role' => $accountUser->getRole(),
87+
'command' => $this->signature,
88+
]);
89+
}
90+
91+
$this->newLine();
92+
$this->info("✓ Successfully assigned SUPERADMIN role to user across $updatedCount account(s).");
93+
$this->warn("⚠️ User {$user->getFullName()} now has COMPLETE SYSTEM ACCESS.");
94+
95+
$this->logger->critical('SUPERADMIN role assignment completed', [
96+
'user_id' => $userId,
97+
'accounts_updated' => $updatedCount,
98+
]);
99+
100+
return self::SUCCESS;
101+
}
102+
}

0 commit comments

Comments
 (0)