From 7adef001b941ea33aac0c7e1da8a28533f94e704 Mon Sep 17 00:00:00 2001 From: Drikus Roor Date: Wed, 15 May 2024 15:34:15 +0200 Subject: [PATCH 1/5] Fix (CI): Fix frontend build in deployment to tst & acc (#1007) * config: Set SENTRY_ENVIRONMENT to "test" and "acceptance" in relevant files so Sentry knows which environment it is running on (#972) * ci: Update podman.yml workflow conditions The `if` conditions in the `podman.yml` workflow file have been updated to include additional checks for the `workflow_dispatch` event. This ensures that the workflow is triggered correctly for the workflow dispatch button in combination with either the `develop` or the `main` branch. * chore: Update podman.yml workflow variables to avoid the vite build failing due to missing environment variables This commit updates the `podman.yml` workflow file to include additional variables related to the frontend HTML. These variables are used for the favicon, logo URL, Open Graph (OG) description, OG image, OG title, OG URL, and body class. The variables are set to empty strings if not provided. This change ensures that the workflow has the necessary variables for the frontend HTML. * ci: Temporarily turn on deploy for acceptance on this branch * chore: Try if manually setting the favicon fixes things * ci: Update podman.yml workflow variables to include frontend HTML environment variables This commit updates the `podman.yml` workflow file to include additional variables related to the frontend HTML. These variables are used for the favicon, logo URL, Open Graph (OG) description, OG image, OG title, OG URL, and body class. The variables are set to empty strings if not provided. This change ensures that the workflow has the necessary variables for the frontend HTML. * ci: Test deploy to test environment * chore: Update podman.yml workflow conditions for develop branch (cherry picked from commit 257b3a7514b51170f2235f0eb6035264e0a780c9) --- .github/workflows/podman.yml | 52 +++++++++++++++++++++++++++--------- 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/.github/workflows/podman.yml b/.github/workflows/podman.yml index 444a5e290..04abcc7ed 100644 --- a/.github/workflows/podman.yml +++ b/.github/workflows/podman.yml @@ -12,7 +12,7 @@ jobs: name: Deploy to test environment environment: Test runs-on: tst - if: github.event_name == 'workflow_dispatch' || github.ref == 'refs/heads/develop' + if: github.ref == 'refs/heads/develop' || (github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main') concurrency: group: ${{ github.workflow }}-${{ github.ref }} env: @@ -32,6 +32,13 @@ jobs: FRONTEND_EXPERIMENT_SLUG: ${{ vars.FRONTEND_EXPERIMENT_SLUG }} FRONTEND_AML_HOME: ${{ vars.FRONTEND_AML_HOME }} FRONTEND_HTML_PAGE_TITLE: ${{ vars.FRONTEND_HTML_PAGE_TITLE }} + FRONTEND_HTML_FAVICON: ${{ vars.FRONTEND_HTML_FAVICON || '' }} + FRONTEND_LOGO_URL: ${{ vars.FRONTEND_LOGO_URL || '' }} + FRONTEND_HTML_OG_DESCRIPTION: ${{ vars.FRONTEND_HTML_OG_DESCRIPTION || '' }} + FRONTEND_HTML_OG_IMAGE: ${{ vars.FRONTEND_HTML_OG_IMAGE || '' }} + FRONTEND_HTML_OG_TITLE: ${{ vars.FRONTEND_HTML_OG_TITLE || '' }} + FRONTEND_HTML_OG_URL: ${{ vars.FRONTEND_HTML_OG_URL || '' }} + FRONTEND_HTML_BODY_CLASS: ${{ vars.FRONTEND_HTML_BODY_CLASS || '' }} # Secrets AML_SECRET_KEY: ${{ secrets.AML_SECRET_KEY }} @@ -51,11 +58,18 @@ jobs: - name: Create .env file run: | touch .env - echo "FRONTEND_API_ROOT=$FRONTEND_API_ROOT" >> .env - echo "FRONTEND_EXPERIMENT_SLUG=$FRONTEND_EXPERIMENT_SLUG" >> .env - echo "FRONTEND_AML_HOME=$FRONTEND_AML_HOME" >> .env - echo "FRONTEND_HTML_PAGE_TITLE=$FRONTEND_HTML_PAGE_TITLE" >> .env - echo "FRONTEND_SENTRY_DSN=$FRONTEND_SENTRY_DSN" >> .env + echo "VITE_API_ROOT=$FRONTEND_API_ROOT" >> .env + echo "VITE_EXPERIMENT_SLUG=$FRONTEND_EXPERIMENT_SLUG" >> .env + echo "VITE_AML_HOME=$FRONTEND_AML_HOME" >> .env + echo "VITE_LOGO_URL=$FRONTEND_LOGO_URL" >> .env + echo "VITE_HTML_FAVICON=$FRONTEND_HTML_FAVICON" >> .env + echo "VITE_HTML_PAGE_TITLE=$FRONTEND_HTML_PAGE_TITLE" >> .env + echo "VITE_HTML_OG_DESCRIPTION=$FRONTEND_HTML_OG_DESCRIPTION" >> .env + echo "VITE_HTML_OG_IMAGE=$FRONTEND_HTML_OG_IMAGE" >> .env + echo "VITE_HTML_OG_TITLE=$FRONTEND_HTML_OG_TITLE" >> .env + echo "VITE_HTML_OG_URL=$FRONTEND_HTML_OG_URL" >> .env + echo "VITE_HTML_BODY_CLASS=$FRONTEND_HTML_BODY_CLASS" >> .env + echo "VITE_SENTRY_DSN=$FRONTEND_SENTRY_DSN" >> .env cp .env frontend/.env - name: Build Podman images run: podman-compose -f docker-compose-deploy.yml build @@ -86,7 +100,7 @@ jobs: name: Deploy to acceptance environment environment: Acceptance runs-on: ACC - if: github.ref == 'refs/heads/main' || github.ref == 'refs/tags/*' + if: github.ref == 'refs/heads/main' || github.ref == 'refs/tags/*' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main') concurrency: group: ${{ github.workflow }}-${{ github.ref }} env: @@ -106,6 +120,13 @@ jobs: FRONTEND_EXPERIMENT_SLUG: ${{ vars.FRONTEND_EXPERIMENT_SLUG }} FRONTEND_AML_HOME: ${{ vars.FRONTEND_AML_HOME }} FRONTEND_HTML_PAGE_TITLE: ${{ vars.FRONTEND_HTML_PAGE_TITLE }} + FRONTEND_HTML_FAVICON: ${{ vars.FRONTEND_HTML_FAVICON || '' }} + FRONTEND_LOGO_URL: ${{ vars.FRONTEND_LOGO_URL || '' }} + FRONTEND_HTML_OG_DESCRIPTION: ${{ vars.FRONTEND_HTML_OG_DESCRIPTION || '' }} + FRONTEND_HTML_OG_IMAGE: ${{ vars.FRONTEND_HTML_OG_IMAGE || '' }} + FRONTEND_HTML_OG_TITLE: ${{ vars.FRONTEND_HTML_OG_TITLE || '' }} + FRONTEND_HTML_OG_URL: ${{ vars.FRONTEND_HTML_OG_URL || '' }} + FRONTEND_HTML_BODY_CLASS: ${{ vars.FRONTEND_HTML_BODY_CLASS || '' }} # Secrets AML_SECRET_KEY: ${{ secrets.AML_SECRET_KEY }} @@ -125,11 +146,18 @@ jobs: - name: Create .env file run: | touch .env - echo "FRONTEND_API_ROOT=$FRONTEND_API_ROOT" >> .env - echo "FRONTEND_EXPERIMENT_SLUG=$FRONTEND_EXPERIMENT_SLUG" >> .env - echo "FRONTEND_AML_HOME=$FRONTEND_AML_HOME" >> .env - echo "FRONTEND_HTML_PAGE_TITLE=$FRONTEND_HTML_PAGE_TITLE" >> .env - echo "FRONTEND_SENTRY_DSN=$FRONTEND_SENTRY_DSN" >> .env + echo "VITE_API_ROOT=$FRONTEND_API_ROOT" >> .env + echo "VITE_EXPERIMENT_SLUG=$FRONTEND_EXPERIMENT_SLUG" >> .env + echo "VITE_AML_HOME=$FRONTEND_AML_HOME" >> .env + echo "VITE_LOGO_URL=$FRONTEND_LOGO_URL" >> .env + echo "VITE_HTML_FAVICON=$FRONTEND_HTML_FAVICON" >> .env + echo "VITE_HTML_PAGE_TITLE=$FRONTEND_HTML_PAGE_TITLE" >> .env + echo "VITE_HTML_OG_DESCRIPTION=$FRONTEND_HTML_OG_DESCRIPTION" >> .env + echo "VITE_HTML_OG_IMAGE=$FRONTEND_HTML_OG_IMAGE" >> .env + echo "VITE_HTML_OG_TITLE=$FRONTEND_HTML_OG_TITLE" >> .env + echo "VITE_HTML_OG_URL=$FRONTEND_HTML_OG_URL" >> .env + echo "VITE_HTML_BODY_CLASS=$FRONTEND_HTML_BODY_CLASS" >> .env + echo "VITE_SENTRY_DSN=$FRONTEND_SENTRY_DSN" >> .env cp .env frontend/.env - name: Build Podman images run: podman-compose -f docker-compose-deploy.yml build From c8bad58ef1a66fffe92b1ea9f21322a3c4f82c47 Mon Sep 17 00:00:00 2001 From: Drikus Roor Date: Wed, 15 May 2024 15:47:41 +0200 Subject: [PATCH 2/5] chore: Update podman.yml workflow conditions for acceptance deployment --- .github/workflows/podman.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/podman.yml b/.github/workflows/podman.yml index 04abcc7ed..0ef98d87b 100644 --- a/.github/workflows/podman.yml +++ b/.github/workflows/podman.yml @@ -5,6 +5,7 @@ on: branches: - develop - main + - fix/deploy-acc workflow_dispatch: jobs: @@ -100,7 +101,7 @@ jobs: name: Deploy to acceptance environment environment: Acceptance runs-on: ACC - if: github.ref == 'refs/heads/main' || github.ref == 'refs/tags/*' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main') + if: true || github.ref == 'refs/heads/main' || github.ref == 'refs/tags/*' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main') concurrency: group: ${{ github.workflow }}-${{ github.ref }} env: From 1d4fdea61bbd141f20323a2354b31c05d5b559df Mon Sep 17 00:00:00 2001 From: Drikus Roor Date: Wed, 15 May 2024 17:34:37 +0200 Subject: [PATCH 3/5] fix: Preload audio without MEDIA_ROOT --- frontend/src/util/webAudio.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/util/webAudio.js b/frontend/src/util/webAudio.js index f98b3e873..0aa344dd6 100644 --- a/frontend/src/util/webAudio.js +++ b/frontend/src/util/webAudio.js @@ -74,7 +74,7 @@ export const changeGain = (level) => { // load sound data and store in buffers object export const loadBuffer = async (id, src, canPlay) => { - await fetch(MEDIA_ROOT + src, {}) + await fetch(src, {}) // Return the data as an ArrayBuffer .then(response => response.arrayBuffer()) // Decode the audio data From 68607f7eb8fb1c138c7bf026264c85bbf4f324fd Mon Sep 17 00:00:00 2001 From: Drikus Roor Date: Thu, 16 May 2024 15:57:20 +0200 Subject: [PATCH 4/5] revert: Do not automatically deploy this PR's commits to acceptance anymore as I (Drikus) have confirmed that Acceptance works again --- .github/workflows/podman.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/podman.yml b/.github/workflows/podman.yml index 0ef98d87b..0608f061e 100644 --- a/.github/workflows/podman.yml +++ b/.github/workflows/podman.yml @@ -5,7 +5,6 @@ on: branches: - develop - main - - fix/deploy-acc workflow_dispatch: jobs: @@ -13,6 +12,8 @@ jobs: name: Deploy to test environment environment: Test runs-on: tst + + # this job runs only on commits to the develop branch or when manually triggered for a branch other than main if: github.ref == 'refs/heads/develop' || (github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main') concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -101,7 +102,9 @@ jobs: name: Deploy to acceptance environment environment: Acceptance runs-on: ACC - if: true || github.ref == 'refs/heads/main' || github.ref == 'refs/tags/*' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main') + + # this job runs only on commits to the main branch, tags, or when manually triggered for the main branch + if: github.ref == 'refs/heads/main' || github.ref == 'refs/tags/*' || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main') concurrency: group: ${{ github.workflow }}-${{ github.ref }} env: From 213c7999a6e795130dbc42c61d714243d41986c0 Mon Sep 17 00:00:00 2001 From: Drikus Roor Date: Thu, 16 May 2024 15:58:11 +0200 Subject: [PATCH 5/5] revert: Revert fix as I will address it in a separate PR --- frontend/src/util/webAudio.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/util/webAudio.js b/frontend/src/util/webAudio.js index 0aa344dd6..f98b3e873 100644 --- a/frontend/src/util/webAudio.js +++ b/frontend/src/util/webAudio.js @@ -74,7 +74,7 @@ export const changeGain = (level) => { // load sound data and store in buffers object export const loadBuffer = async (id, src, canPlay) => { - await fetch(src, {}) + await fetch(MEDIA_ROOT + src, {}) // Return the data as an ArrayBuffer .then(response => response.arrayBuffer()) // Decode the audio data