From bcc94c3184a26a3cb1eea0a6ac370e72c8c7393e Mon Sep 17 00:00:00 2001 From: Alex Tkachev Date: Mon, 16 Dec 2024 13:42:39 +0400 Subject: [PATCH 1/3] fix: make decap env vars available in the fe_build workflow 1. AmazeeLabs/publisher-action should define the vars before the prep step as Vite bundles them into the build. 2. The env vars should be available in the publisher image. 3. Publisher app should send the vars to the Github workflow. --- .github/workflows/fe_build.yml | 14 +++++++------- .lagoon/Dockerfile | 5 +++++ apps/publisher/publisher.config.ts | 2 ++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/.github/workflows/fe_build.yml b/.github/workflows/fe_build.yml index eda59b86c..b54a8bab1 100644 --- a/.github/workflows/fe_build.yml +++ b/.github/workflows/fe_build.yml @@ -34,13 +34,6 @@ jobs: server-token: 'local' repo-token: ${{ secrets.GITHUB_TOKEN }} - - name: Prepare - run: SKIP_DRUPAL_INSTALL=1 pnpm turbo:prep - env: - TURBO_API: 'http://127.0.0.1:9080' - TURBO_TOKEN: 'local' - TURBO_TEAM: 'local' - - name: Publisher uses: AmazeeLabs/publisher-action@4371b4a90a9fe2c86248e76c0f428e39abf6b610 with: @@ -50,6 +43,13 @@ jobs: apps/website/public cache_key: 'fe-build-${{ inputs.env }}' + - name: Prepare + run: SKIP_DRUPAL_INSTALL=1 pnpm turbo:prep + env: + TURBO_API: 'http://127.0.0.1:9080' + TURBO_TOKEN: 'local' + TURBO_TEAM: 'local' + - name: Build & deploy run: | set -ex diff --git a/.lagoon/Dockerfile b/.lagoon/Dockerfile index 2a0319b1a..3079a6574 100644 --- a/.lagoon/Dockerfile +++ b/.lagoon/Dockerfile @@ -118,4 +118,9 @@ RUN npm install -g pnpm@8.15.9 COPY --from=builder /tmp/.deploy/publisher /app +# Decap config. +ENV VITE_DECAP_REPO='AmazeeLabs/silverback-template' +ARG LAGOON_GIT_BRANCH +ENV VITE_DECAP_BRANCH="$LAGOON_GIT_BRANCH" + CMD pnpm publisher diff --git a/apps/publisher/publisher.config.ts b/apps/publisher/publisher.config.ts index 4f40ae0e4..65111013a 100644 --- a/apps/publisher/publisher.config.ts +++ b/apps/publisher/publisher.config.ts @@ -72,6 +72,8 @@ function githubEnvVars(): Record { 'PUBLISHER_OAUTH2_SESSION_SECRET', 'PUBLISHER_OAUTH2_ENVIRONMENT_TYPE', 'PUBLISHER_OAUTH2_TOKEN_HOST', + 'VITE_DECAP_REPO', + 'VITE_DECAP_BRANCH', ].map((name) => { if (name === 'DRUPAL_INTERNAL_URL') { // No internal URLs when building on Github. From 7d8b38f0d2342e0b99c0ac5d4ecc017c9e5663cf Mon Sep 17 00:00:00 2001 From: Alex Tkachev Date: Mon, 16 Dec 2024 13:48:02 +0400 Subject: [PATCH 2/3] fix: fix edge functions --- .github/workflows/fe_build.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/fe_build.yml b/.github/workflows/fe_build.yml index b54a8bab1..50d5a3cd5 100644 --- a/.github/workflows/fe_build.yml +++ b/.github/workflows/fe_build.yml @@ -68,10 +68,16 @@ jobs: pnpm build:gatsby fi + # "netlify deploy" fails to locate edge functions when executed from a + # monorepo. Flags like --cwd or --filter do not help. So we deploy the + # website app to a dedicated folder first. + pnpm deploy --filter "@custom/website" /tmp/deploy --prod + cd /tmp/deploy + # Deploy pnpm netlify env:set AWS_LAMBDA_JS_RUNTIME nodejs18.x pnpm netlify env:set DRUPAL_EXTERNAL_URL $DRUPAL_EXTERNAL_URL - pnpm netlify deploy --cwd=. --dir=apps/website/public --prodIfUnlocked + pnpm netlify deploy --prodIfUnlocked # Report success to Publisher echo "BUILD_IS_SUCCESSFUL=1" >> $GITHUB_ENV From af90c39cfd37a8679a3ade4840e74e728f46ce36 Mon Sep 17 00:00:00 2001 From: Alex Tkachev Date: Mon, 16 Dec 2024 13:49:04 +0400 Subject: [PATCH 3/3] fix: use direct import to solve "Cannot find package" error --- apps/website/netlify/functions/github-proxy.mts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/website/netlify/functions/github-proxy.mts b/apps/website/netlify/functions/github-proxy.mts index 105495b11..117d6871f 100644 --- a/apps/website/netlify/functions/github-proxy.mts +++ b/apps/website/netlify/functions/github-proxy.mts @@ -1,6 +1,7 @@ -import { githubProxy } from '@amazeelabs/decap-cms-backend-token-auth/proxy'; import type { Context } from '@netlify/functions'; +import { githubProxy } from '../../node_modules/@amazeelabs/decap-cms-backend-token-auth/build/proxy.js'; + // eslint-disable-next-line @typescript-eslint/no-unused-vars export default function (request: Request, context: Context) { if (!process.env.DECAP_GITHUB_TOKEN) {