From 6e0f22323be5688037d53691df2d9a0c8063e774 Mon Sep 17 00:00:00 2001 From: Geometrically <18202329+Geometrically@users.noreply.github.com> Date: Mon, 3 Jul 2023 18:08:05 -0700 Subject: [PATCH] Fix pages env vars (#1230) * Fix pages env vars * bring back vercel json --- .github/workflows/deploy.yml | 19 +++++++++++++++++++ .github/workflows/regenerate.yml | 2 +- nuxt.config.ts | 11 +++++++++-- 3 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 000000000..5b0e3e2b5 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,19 @@ +name: Deploy + +on: push + +jobs: + deploy: + runs-on: ubuntu-latest + permissions: + contents: read + deployments: write + steps: + - name: Cloudflare Pages deployment + uses: WalshyDev/cf-pages-await@v1 + with: + apiToken: ${{ secrets.CF_API_TOKEN }} + accountId: '9ddae624c98677d68d93df6e524a6061' + project: 'knossos' + githubToken: ${{ secrets.GITHUB_TOKEN }} + commitHash: ${{ steps.push-changes.outputs.commit-hash }} diff --git a/.github/workflows/regenerate.yml b/.github/workflows/regenerate.yml index b5a9c0b59..242c72092 100644 --- a/.github/workflows/regenerate.yml +++ b/.github/workflows/regenerate.yml @@ -11,4 +11,4 @@ jobs: - name: Re-deploy site run: | curl -X POST \ - ${{ secrets.VERCEL_DEPLOY_URL }} + ${{ secrets.CLOUDFLARE_DEPLOY_URL }} diff --git a/nuxt.config.ts b/nuxt.config.ts index ba7798de6..7db53eff4 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -269,8 +269,10 @@ export default defineNuxtConfig({ owner: process.env.VERCEL_GIT_REPO_OWNER || 'modrinth', slug: process.env.VERCEL_GIT_REPO_SLUG || 'knossos', - branch: process.env.VERCEL_GIT_COMMIT_REF || 'master', - hash: process.env.VERCEL_GIT_COMMIT_SHA || 'unknown', + // @ts-ignore + branch: process.env.VERCEL_GIT_COMMIT_REF || globalThis.CF_PAGES_BRANCH || 'master', + // @ts-ignore + hash: process.env.VERCEL_GIT_COMMIT_SHA || globalThis.CF_PAGES_COMMIT_SHA || 'unknown', }, }, typescript: { @@ -309,6 +311,11 @@ function getDomain() { if (process.env.NODE_ENV === 'production') { if (process.env.SITE_URL) { return process.env.SITE_URL + } + // @ts-ignore + else if (process.env.CF_PAGES_URL || globalThis.CF_PAGES_URL) { + // @ts-ignore + return process.env.CF_PAGES_URL ?? globalThis.CF_PAGES_URL } else if (process.env.HEROKU_APP_NAME) { return `https://${process.env.HEROKU_APP_NAME}.herokuapp.com` } else if (process.env.VERCEL_URL) {