From ef55ba875ac5e5cba11af248bdf032e29cebb1fe Mon Sep 17 00:00:00 2001 From: Anand Chowdhary Date: Mon, 10 Aug 2020 13:34:01 +0530 Subject: [PATCH] :wrench: Add post-process for CNAME --- .github/workflows/site.yml | 2 ++ site/post-process.ts | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 site/post-process.ts diff --git a/.github/workflows/site.yml b/.github/workflows/site.yml index 28fca6cb..6078bcae 100644 --- a/.github/workflows/site.yml +++ b/.github/workflows/site.yml @@ -19,6 +19,8 @@ jobs: run: cd site && npm ci - name: Build site run: cd site && npm run export + - name: Post process site + run: npx ts-node site/post-process.ts env: NODE_ENV: "production" - uses: maxheld83/ghpages@v0.2.1 diff --git a/site/post-process.ts b/site/post-process.ts new file mode 100644 index 00000000..ead31bb6 --- /dev/null +++ b/site/post-process.ts @@ -0,0 +1,17 @@ +import fs from "fs"; +import { join } from "path"; + +export const postProcess = () => { + const configFile = fs.readFileSync(join(".", ".statusrc.yml")).toString(); + const cnameLine = configFile + .split("\n") + .find((line) => line.includes("cname:")); + if (cnameLine) { + fs.writeFileSync( + join(".", "site", "__export__", "CNAME"), + cnameLine.split("cname:")[1].trim() + ); + } +}; + +postProcess();