diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index da457b2..37a4d21 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -5,6 +5,7 @@ on: push: branches: - main + workflow_dispatch: permissions: pull-requests: write id-token: write diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 0c55cdd..04f80eb 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -9,11 +9,6 @@ on: payum-apikey: description: Payum API Key required: true - sms-dsn: - description: SMS DSN - required: true - mailer-dsn: - description: MAILER DSN storage-key: description: storage key required: true @@ -29,6 +24,12 @@ on: database-url: description: Database URL required: true + mailer-dsn: + description: Mailer DSN + required: true + sms-dsn: + description: SMS DSN + required: true jobs: @@ -44,6 +45,7 @@ jobs: project: ${{ steps.meta.outputs.project }} namespace: ${{ steps.meta.outputs.namespace }} storage_name: ${{ steps.meta.outputs.storage_name }} + trusted_host: ${{ steps.meta.outputs.trusted_host }} steps: - name: Generate metadata id: meta @@ -55,6 +57,9 @@ jobs: ENVIRONMENT=prod IMAGE_TAG=sha-${GITHUB_SHA::7} RELEASE_NAME=prod + TRUSTED_HOST=$(echo ${{ vars.DOMAIN }} | sed 's/\./\\\\\\\\./g') + + echo "trusted_host=${TRUSTED_HOST}" >> $GITHUB_OUTPUT echo "context=${CONTEXT}" >> $GITHUB_OUTPUT echo "environment=${ENVIRONMENT}" >> $GITHUB_OUTPUT echo "image_tag=${IMAGE_TAG}" >> $GITHUB_OUTPUT @@ -120,15 +125,18 @@ jobs: --set=ingress.tls[0].hosts[0]=${{ vars.DOMAIN }} \ --set=postgresql.url="${{ secrets.database-url }}" \ --set=postgresql.enabled='${{ github.event_name == 'pull_request' }}' \ - --set=sms.dsn="${{ secrets.sms-dsn }}" \ --set=payum.apikey="${{ secrets.payum-apikey }}" \ --set=mailer.dsn="${{ secrets.mailer-dsn }}" \ + --set=sms.dsn="${{ secrets.sms-dsn }}" \ --set=php.storage.bucket="${{ vars.STORAGE_BUCKET }}" \ --set=php.storage.endpoint="https://storage.googleapis.com" \ --set=php.storage.region="eu-west-1" \ --set=php.storage.usePathStyleEndpoint=true \ --set=php.storage.key="${{ secrets.storage-key }}" \ --set=php.storage.secret="${{ secrets.storage-secret-key }}" \ + --set=php.trustedHosts[2]=${{ needs.meta.outputs.trusted_host }} \ + --set=php.fixtureJob.enabled=false \ + --set=php.fixtureCron.enabled=false \ --values ./helm/chart/values-${{ needs.meta.outputs.context }}.yml \ | sed --unbuffered '/USER-SUPPLIED VALUES/,$d' ; then echo "Deployment has failed!" diff --git a/Dockerfile b/Dockerfile index bc3bb4c..77830db 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ # https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact ARG PHP_VERSION=8.1 -ARG CADDY_VERSION=2.8.4 +ARG CADDY_VERSION=2.9.1 # yarn build FROM gmolaire/yarn AS yarn_build @@ -183,12 +183,7 @@ RUN set -eux; \ RUN rm -f .env.local.php # Build Caddy with the Mercure and Vulcain modules -# FROM caddy:${CADDY_VERSION}-builder-alpine AS app_caddy_builder - -# Temporary fix for https://github.com/dunglas/mercure/issues/770 -# https://github.com/dunglas/symfony-docker/pull/407/files - -FROM caddy:2.8.4-builder-alpine AS app_caddy_builder +FROM caddy:${CADDY_VERSION}-builder-alpine AS app_caddy_builder # RUN xcaddy build \ # --with github.com/dunglas/mercure \ diff --git a/composer.lock b/composer.lock index 357f301..97db592 100644 --- a/composer.lock +++ b/composer.lock @@ -4512,16 +4512,16 @@ }, { "name": "league/commonmark", - "version": "2.5.3", + "version": "2.6.0", "source": { "type": "git", "url": "https://github.com/thephpleague/commonmark.git", - "reference": "b650144166dfa7703e62a22e493b853b58d874b0" + "reference": "d150f911e0079e90ae3c106734c93137c184f932" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/b650144166dfa7703e62a22e493b853b58d874b0", - "reference": "b650144166dfa7703e62a22e493b853b58d874b0", + "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/d150f911e0079e90ae3c106734c93137c184f932", + "reference": "d150f911e0079e90ae3c106734c93137c184f932", "shasum": "" }, "require": { @@ -4546,8 +4546,9 @@ "phpstan/phpstan": "^1.8.2", "phpunit/phpunit": "^9.5.21 || ^10.5.9 || ^11.0.0", "scrutinizer/ocular": "^1.8.1", - "symfony/finder": "^5.3 | ^6.0 || ^7.0", - "symfony/yaml": "^2.3 | ^3.0 | ^4.0 | ^5.0 | ^6.0 || ^7.0", + "symfony/finder": "^5.3 | ^6.0 | ^7.0", + "symfony/process": "^5.4 | ^6.0 | ^7.0", + "symfony/yaml": "^2.3 | ^3.0 | ^4.0 | ^5.0 | ^6.0 | ^7.0", "unleashedtech/php-coding-standard": "^3.1.1", "vimeo/psalm": "^4.24.0 || ^5.0.0" }, @@ -4557,7 +4558,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "2.6-dev" + "dev-main": "2.7-dev" } }, "autoload": { @@ -4614,7 +4615,7 @@ "type": "tidelift" } ], - "time": "2024-08-16T11:46:16+00:00" + "time": "2024-12-07T15:34:16+00:00" }, { "name": "league/config", @@ -19750,7 +19751,7 @@ ], "aliases": [], "minimum-stability": "beta", - "stability-flags": {}, + "stability-flags": [], "prefer-stable": true, "prefer-lowest": false, "platform": { @@ -19762,6 +19763,6 @@ "ext-xsl": "*", "ext-zip": "*" }, - "platform-dev": {}, + "platform-dev": [], "plugin-api-version": "2.6.0" } diff --git a/config/packages/monolog.yaml b/config/packages/monolog.yaml index 8c9efa9..53c4fd0 100644 --- a/config/packages/monolog.yaml +++ b/config/packages/monolog.yaml @@ -56,6 +56,6 @@ when@prod: process_psr_3_messages: false channels: ["!event", "!doctrine"] deprecation: - type: stream + type: "null" channels: [deprecation] path: php://stderr diff --git a/config/packages/notifier.yaml b/config/packages/notifier.yaml index ce92ec6..c2fe07d 100644 --- a/config/packages/notifier.yaml +++ b/config/packages/notifier.yaml @@ -6,10 +6,10 @@ framework: channel_policy: # use chat/slack, chat/telegram, sms/twilio or sms/nexmo - urgent: ['email'] - high: ['email'] - medium: ['email'] - low: ['email'] + urgent: ['sms','email'] + high: ['sms','email'] + medium: ['sms','email'] + low: ['sms','email'] admin_recipients: - { email: admin@example.com } diff --git a/fixtures/prod b/fixtures/prod index b59f7e3..63e96b8 120000 --- a/fixtures/prod +++ b/fixtures/prod @@ -1 +1 @@ -test/ \ No newline at end of file +prod-boot/ \ No newline at end of file diff --git a/helm/chart/templates/configmap.yaml b/helm/chart/templates/configmap.yaml index f15cbd2..67bbe47 100644 --- a/helm/chart/templates/configmap.yaml +++ b/helm/chart/templates/configmap.yaml @@ -10,7 +10,7 @@ data: php-app-env: {{ .Values.php.appEnv | quote }} php-app-debug: {{ .Values.php.appDebug | quote }} php-cors-allow-origin: {{ .Values.php.corsAllowOrigin | quote }} - php-trusted-hosts: {{ .Values.php.trustedHosts | quote }} + php-trusted-hosts: {{ join "|" .Values.php.trustedHosts | quote }} php-trusted-proxies: "{{ join "," .Values.php.trustedProxies }}" mercure-url: "http://{{ include "plateforme-ebs" . }}/.well-known/mercure" mercure-public-url: {{ .Values.mercure.publicUrl | default "http://127.0.0.1/.well-known/mercure" | quote }} diff --git a/helm/chart/templates/cronjob-fixture-reset.yaml b/helm/chart/templates/cronjob-fixture-reset.yaml index f061c69..e763fa4 100644 --- a/helm/chart/templates/cronjob-fixture-reset.yaml +++ b/helm/chart/templates/cronjob-fixture-reset.yaml @@ -200,4 +200,4 @@ spec: periodSeconds: 3 resources: {{- toYaml .Values.resources.fixtures | nindent 16 }} -{{- end }} \ No newline at end of file +{{- end }} diff --git a/helm/chart/templates/fixtures-job.yaml b/helm/chart/templates/fixtures-job.yaml index 7faa6cf..09363bb 100644 --- a/helm/chart/templates/fixtures-job.yaml +++ b/helm/chart/templates/fixtures-job.yaml @@ -1,4 +1,4 @@ -{{- if .Values.php.fixtureJob.enabled -}} +{{- if .Values.php.fixtureJob.enabled }} apiVersion: batch/v1 kind: Job metadata: diff --git a/helm/chart/values-prod.yml b/helm/chart/values-prod.yml index c644cc5..e810596 100644 --- a/helm/chart/values-prod.yml +++ b/helm/chart/values-prod.yml @@ -33,6 +33,6 @@ postgresql: php: fixtureJob: - enabled: true + enabled: false fixtureCron: - enabled: true + enabled: false diff --git a/helm/chart/values.yaml b/helm/chart/values.yaml index 5eee356..a0565d8 100644 --- a/helm/chart/values.yaml +++ b/helm/chart/values.yaml @@ -12,7 +12,10 @@ php: appDebug: "0" appSecret: "" corsAllowOrigin: "^https?://.*?\\.chart-example\\.local$" - trustedHosts: "^127\\.0\\.0\\.1|localhost|.*\\.chart-example\\.local$" + trustedHosts: + - "^127\\.0\\.0\\.1" + - "localhost" + - ".*\\.chart-example\\.local$" trustedProxies: - "127.0.0.1" - "10.0.0.0/8" diff --git a/src/Notifier/SmsNotifier.php b/src/Notifier/SmsNotifier.php index 6733658..2cd959b 100644 --- a/src/Notifier/SmsNotifier.php +++ b/src/Notifier/SmsNotifier.php @@ -26,7 +26,10 @@ final class SmsNotifier public function notify(User $user, string $subject): ?SentMessage { + $this->logger->info('SMS Notification'); if (!$user->canBeNotifiedBySms()) { + $this->logger->warning('User cannot be notified by SMS'); + return null; } @@ -43,10 +46,13 @@ final class SmsNotifier } try { - return $this->texter->send(new SmsMessage( + $response = $this->texter->send(new SmsMessage( phone: $phoneNumber, subject: $subject )); + $this->logger->info('SMS Sent Successfully'); + + return $response; } catch (\Exception $e) { // OK, the sms cannot be delivered, but this is not critical as the an // email is always sent diff --git a/src/Repository/ConfigurationRepository.php b/src/Repository/ConfigurationRepository.php index c2f392d..18ff75d 100644 --- a/src/Repository/ConfigurationRepository.php +++ b/src/Repository/ConfigurationRepository.php @@ -61,13 +61,13 @@ final class ConfigurationRepository extends ServiceEntityRepository public function getServicesParameter(): bool { - /** @var array{configuration: array{ global: array{ globalServicesEnabled: bool }}} $config */ + /** @var array{configuration: array{ global: array{ globalServicesEnabled: bool|null }}} $config */ $config = $this ->createQueryBuilder('c') ->select('c.configuration') ->setMaxResults(1) ->getQuery()->getOneOrNullResult(); - return $config['configuration']['global']['globalServicesEnabled']; + return $config['configuration']['global']['globalServicesEnabled'] ?? false; } }