From a331eb5f1c35f321d94633af41dcf4fb316d2ec0 Mon Sep 17 00:00:00 2001 From: lorcan-codes <126797224+lorcan-codes@users.noreply.github.com> Date: Tue, 7 Nov 2023 18:53:25 +0500 Subject: [PATCH] Use env values in configs (#1554) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Use env values in configs * deploy cms to new org * add deployment to old cms config * deploy auth cms to the new org * seperate config auth cms old * add manual deployment * add push trigger * add branch to trigger * use new org auth url * add whitelist callback * deploy to productin * update whitelist urls * remove hard coded url * remove hard coded url - WIP * update whitelist config * redeploy cms and auth * Update Page “online-communities” * cleanup * use old pipeline trigger * fix event issue * Test deployment --------- Co-authored-by: bgharbi Co-authored-by: AmalyStark <129071621+AmalyStark@users.noreply.github.com> --- .github/workflows/netlify-cms-auth.yml | 3 +- .github/workflows/netlify-cms.yml | 11 +-- .github/workflows/website.yml | 14 ++-- .github/workflows/website_old.yml | 83 ------------------- _data/pages/online-communities.yml | 4 + workspaces/cms-config/src/main.ts | 2 +- workspaces/netlify-cms-auth/src/callback.ts | 2 + workspaces/netlify-cms-auth/src/env.ts | 4 +- workspaces/netlify-cms/src/App.tsx | 2 + .../src/components/Button/ButtonStyles.ts | 2 +- 10 files changed, 27 insertions(+), 100 deletions(-) delete mode 100644 .github/workflows/website_old.yml diff --git a/.github/workflows/netlify-cms-auth.yml b/.github/workflows/netlify-cms-auth.yml index 8cdb9de726..ce3ab6d401 100644 --- a/.github/workflows/netlify-cms-auth.yml +++ b/.github/workflows/netlify-cms-auth.yml @@ -3,7 +3,8 @@ name: Build and Deploy Netlify CMS Auth on: push: branches: - - deploy/netlify-cms-auth + - deploy/netlify-cms-auth + workflow_dispatch: jobs: build_and_deploy: diff --git a/.github/workflows/netlify-cms.yml b/.github/workflows/netlify-cms.yml index 2af2fd17e5..e7067c2e8f 100644 --- a/.github/workflows/netlify-cms.yml +++ b/.github/workflows/netlify-cms.yml @@ -8,7 +8,7 @@ jobs: name: Build and Deploy environment: name: Netlify CMS ${{ github.ref_name }} - url: https://${{ env.GITHUB_REF_SLUG_URL }}.starknet-netlify-cms.pages.dev + url: https://${{ env.GITHUB_REF_SLUG_URL }}.starknet-netlify-cms-byd.pages.dev permissions: contents: read deployments: write @@ -47,10 +47,11 @@ jobs: - name: Build Netlify CMS run: yarn workspace @starknet-io/netlify-cms build env: - VITE_LIVE_PREVIEW_URL: https://${{ env.GITHUB_REF_SLUG_URL }}.starknet-website.pages.dev + VITE_LIVE_PREVIEW_URL: https://${{ env.GITHUB_REF_SLUG_URL }}.starknet-websites.pages.dev VITE_GIT_BRANCH_NAME: ${{ github.ref_name }} - VITE_API_BASE_URL: https://${{ env.GITHUB_REF_SLUG_URL }}.starknet-website.pages.dev/api - VITE_DATA_URL: https://${{ env.GITHUB_REF_SLUG_URL }}.starknet-website.pages.dev/data + VITE_API_BASE_URL: https://${{ env.GITHUB_REF_SLUG_URL }}.starknet-websites.pages.dev/api + VITE_DATA_URL: https://${{ env.GITHUB_REF_SLUG_URL }}.starknet-websites.pages.dev/data + VITE_BACKEND_AUTH_URL: https://netlify-cms-auth.haim-6b2.workers.dev - name: Deploy Netlify CMS uses: cloudflare/pages-action@1 @@ -60,4 +61,4 @@ jobs: projectName: starknet-netlify-cms directory: workspaces/netlify-cms/dist gitHubToken: ${{ secrets.GITHUB_TOKEN }} - branch: ${{ github.ref_name }} + branch: main diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index 6642468cef..de11822ade 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -64,17 +64,17 @@ jobs: VITE_ALGOLIA_INDEX: ${{ github.ref_name == 'production' && 'production' || 'dev' }} VITE_ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }} VITE_ALGOLIA_SEARCH_API_KEY: ${{ secrets.ALGOLIA_SEARCH_API_KEY }} - VITE_CF_STREAM_URL: ${{ secrets.NEW_CF_STREAM_URL }} - VITE_ED_VIDEO_ID_1: ${{ secrets.NEW_VITE_ED_VIDEO_ID_1 }} - VITE_ED_VIDEO_ID_2: ${{ secrets.NEW_VITE_ED_VIDEO_ID_2 }} - VITE_ED_VIDEO_ID_3: ${{ secrets.NEW_VITE_ED_VIDEO_ID_3 }} - VITE_ED_VIDEO_ID_4: ${{ secrets.NEW_VITE_ED_VIDEO_ID_4 }} + VITE_CF_STREAM_URL: ${{ secrets.CF_STREAM_URL }} + VITE_ED_VIDEO_ID_1: ${{ secrets.VITE_ED_VIDEO_ID_1 }} + VITE_ED_VIDEO_ID_2: ${{ secrets.VITE_ED_VIDEO_ID_2 }} + VITE_ED_VIDEO_ID_3: ${{ secrets.VITE_ED_VIDEO_ID_3 }} + VITE_ED_VIDEO_ID_4: ${{ secrets.VITE_ED_VIDEO_ID_4 }} - name: Publish uses: cloudflare/pages-action@v1 with: - apiToken: ${{ secrets.NEW_CLOUDFLARE_API_TOKEN }} - accountId: ${{ secrets.NEW_CLOUDFLARE_ACCOUNT_ID }} + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} projectName: starknet-websites directory: dist/client workingDirectory: workspaces/website diff --git a/.github/workflows/website_old.yml b/.github/workflows/website_old.yml deleted file mode 100644 index 940f681932..0000000000 --- a/.github/workflows/website_old.yml +++ /dev/null @@ -1,83 +0,0 @@ -name: Build and Deploy Starknet Website - -on: - push: - -jobs: - build: - name: Build and Deploy - environment: - name: Starknet Website ${{ github.ref_name }} - url: https://${{ env.GITHUB_REF_SLUG_URL }}.starknet-website.pages.dev - runs-on: ubuntu-22.04 - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup Node.js - uses: actions/setup-node@v3 - with: - node-version: 18 - cache: yarn - - - name: Cache dependencies - uses: actions/cache@v3 - with: - path: | - .yarn/cache - .yarn/install-state.gz - .eslintcache - **/tsconfig.tsbuildinfo - **/.types/** - **/.types-*/** - key: build-cache-${{ hashFiles('yarn.lock') }} - restore-keys: | - build-cache- - - - name: Install dependencies - run: yarn - - - name: Restore Crowdin Cache - uses: actions/cache/restore@v3 - with: - path: _crowdin - key: crowdin-cache-dev - - - name: Update dynamic data - run: yarn workspace @starknet-io/cms-scripts update-dynamic-data - - - name: Inject slug/short variables - uses: rlespinasse/github-slug-action@v4 - with: - slug-maxlength: 28 - - - name: Set VITE_SITE_URL - run: | - if [ "${{ env.GITHUB_REF_SLUG_URL }}" = "production" ]; then - echo "VITE_SITE_URL=https://www.starknet.io" >> $GITHUB_ENV - else - echo "VITE_SITE_URL=https://${{ env.GITHUB_REF_SLUG_URL }}.starknet-website.pages.dev" >> $GITHUB_ENV - fi - - - name: Build project - run: yarn workspace @starknet-io/website build - env: - VITE_ALGOLIA_INDEX: ${{ github.ref_name == 'production' && 'production' || 'dev' }} - VITE_ALGOLIA_APP_ID: ${{ secrets.ALGOLIA_APP_ID }} - VITE_ALGOLIA_SEARCH_API_KEY: ${{ secrets.ALGOLIA_SEARCH_API_KEY }} - VITE_CF_STREAM_URL: ${{ secrets.CF_STREAM_URL }} - VITE_ED_VIDEO_ID_1: ${{ secrets.VITE_ED_VIDEO_ID_1 }} - VITE_ED_VIDEO_ID_2: ${{ secrets.VITE_ED_VIDEO_ID_2 }} - VITE_ED_VIDEO_ID_3: ${{ secrets.VITE_ED_VIDEO_ID_3 }} - VITE_ED_VIDEO_ID_4: ${{ secrets.VITE_ED_VIDEO_ID_4 }} - - - name: Publish - uses: cloudflare/pages-action@v1 - with: - apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} - accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - projectName: starknet-website - directory: dist/client - workingDirectory: workspaces/website - wranglerVersion: '3' - gitHubToken: ${{ secrets.GITHUB_TOKEN }} - branch: ${{ github.ref_name == 'production' && 'main' || github.ref_name }} diff --git a/_data/pages/online-communities.yml b/_data/pages/online-communities.yml index 77f3e0d167..33da172c96 100644 --- a/_data/pages/online-communities.yml +++ b/_data/pages/online-communities.yml @@ -112,6 +112,10 @@ blocks: hasIcon: true custom_title: Starknet Ecosystem custom_external_link: https://twitter.com/StarknetEco + - link: + hasIcon: true + custom_title: Starknet France + custom_external_link: https://twitter.com/StarknetFr - link: hasIcon: true custom_title: "Starknet Gaming " diff --git a/workspaces/cms-config/src/main.ts b/workspaces/cms-config/src/main.ts index ec5376b8e1..d6667ab60b 100644 --- a/workspaces/cms-config/src/main.ts +++ b/workspaces/cms-config/src/main.ts @@ -12,7 +12,7 @@ export const CMSConfig = { name: "github-yuki", repo: "starknet-io/starknet-website", branch: "dev", - base_url: "https://netlify-cms-auth.yukilabs.workers.dev", + base_url: "https://netlify-cms-auth.haim-6b2.workers.dev", preview_context: "Vercel – starknet-website", }, publish_mode: "editorial_workflow", diff --git a/workspaces/netlify-cms-auth/src/callback.ts b/workspaces/netlify-cms-auth/src/callback.ts index 2f0313f693..8772812dbb 100644 --- a/workspaces/netlify-cms-auth/src/callback.ts +++ b/workspaces/netlify-cms-auth/src/callback.ts @@ -62,6 +62,8 @@ function postMessageHTML({ status, data }: PostMessageHTMLArgs) { const allowedOrigin = ( message.origin === 'http://localhost:1234' || message.origin === 'http://127.0.0.1:1234' || + message.origin === 'https://starknet-netlify-cms-byd.pages.dev' || + /^https:\\/\\/[-_\\w]+\\.starknet-netlify-cms-byd\\.pages\\.dev$/.test(message.origin) || /^https:\\/\\/[-_\\w]+\\.starknet-netlify-cms\\.pages\\.dev$/.test(message.origin) ); diff --git a/workspaces/netlify-cms-auth/src/env.ts b/workspaces/netlify-cms-auth/src/env.ts index 8050439f19..adf3325a1b 100644 --- a/workspaces/netlify-cms-auth/src/env.ts +++ b/workspaces/netlify-cms-auth/src/env.ts @@ -1,4 +1,4 @@ export interface Env { - OAUTH_GITHUB_CLIENT_ID: string - OAUTH_GITHUB_CLIENT_SECRET: string + OAUTH_GITHUB_CLIENT_ID: string; + OAUTH_GITHUB_CLIENT_SECRET: string; } diff --git a/workspaces/netlify-cms/src/App.tsx b/workspaces/netlify-cms/src/App.tsx index 96a5e7b1c2..e244aadfde 100644 --- a/workspaces/netlify-cms/src/App.tsx +++ b/workspaces/netlify-cms/src/App.tsx @@ -110,6 +110,8 @@ export default function App() { backend: { ...CMSConfig.backend, branch, + base_url: + import.meta.env.VITE_BACKEND_AUTH_URL || CMSConfig.backend.base_url, }, }, }); diff --git a/workspaces/website/src/components/Button/ButtonStyles.ts b/workspaces/website/src/components/Button/ButtonStyles.ts index 5b847b3a45..ab37d43c67 100644 --- a/workspaces/website/src/components/Button/ButtonStyles.ts +++ b/workspaces/website/src/components/Button/ButtonStyles.ts @@ -19,7 +19,7 @@ const outline = defineStyle({ borderColor: "grey.morning", _dark: { color: "selected.100" - } + }, }, _active: { bg: "bg.200",