From 77ad8950986aebcd8ed5f966492e710d6bde7ae3 Mon Sep 17 00:00:00 2001
From: Yangshun Tay <tay.yang.shun@gmail.com>
Date: Tue, 11 Oct 2022 07:43:29 +0800
Subject: [PATCH] [infra] add GitHub actions for linting (#357)

---
 .github/workflows/lint.yml     | 44 ++++++++++++++++++++++++++++++++++
 apps/portal/src/env/schema.mjs |  6 ++++-
 2 files changed, 49 insertions(+), 1 deletion(-)
 create mode 100644 .github/workflows/lint.yml

diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
new file mode 100644
index 00000000..7c2fd46d
--- /dev/null
+++ b/.github/workflows/lint.yml
@@ -0,0 +1,44 @@
+# Copied from https://github.com/facebook/docusaurus/blob/main/.github/workflows/lint.yml
+name: Lint
+
+on:
+  pull_request:
+    branches:
+      - main
+
+concurrency:
+  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
+  cancel-in-progress: true
+
+permissions:
+  contents: read
+
+env:
+  DATABASE_URL: 'postgresql://postgres:password@localhost:5432/postgres'
+  GITHUB_CLIENT_ID: '1234'
+  GITHUB_CLIENT_SECRET: 'abcd'
+  NEXTAUTH_SECRET: 'efgh'
+  NEXTAUTH_URL: 'http://localhost:3000'
+  NODE_ENV: test
+  SUPABASE_ANON_KEY: 'ijkl'
+  SUPABASE_URL: 'https://abcd.supabase.co'
+
+jobs:
+  lint:
+    name: Lint
+    timeout-minutes: 30
+    runs-on: ubuntu-latest
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v3
+      - name: Set up Node
+        uses: actions/setup-node@v3
+        with:
+          node-version: '16'
+          cache: yarn
+      - name: Installation
+        run: yarn
+      - name: Check immutable yarn.lock
+        run: git diff --exit-code
+      - name: Lint
+        run: yarn lint
diff --git a/apps/portal/src/env/schema.mjs b/apps/portal/src/env/schema.mjs
index 69064437..404f12cf 100644
--- a/apps/portal/src/env/schema.mjs
+++ b/apps/portal/src/env/schema.mjs
@@ -4,6 +4,8 @@ import { z } from 'zod';
 /**
  * Specify your server-side environment variables schema here.
  * This way you can ensure the app isn't built with invalid env vars.
+ *
+ * Remember to update existing GitHub workflows that use env vars!
  */
 export const serverSchema = z.object({
   DATABASE_URL: z.string().url(),
@@ -20,13 +22,15 @@ export const serverSchema = z.object({
  * Specify your client-side environment variables schema here.
  * This way you can ensure the app isn't built with invalid env vars.
  * To expose them to the client, prefix them with `NEXT_PUBLIC_`.
+ *
+ * Remember to update existing GitHub workflows that use env vars!
  */
 export const clientSchema = z.object({
   // NEXT_PUBLIC_BAR: z.string(),
 });
 
 /**
- * You can't destruct `process.env` as a regular object, so you have to do
+ * You can't destructure `process.env` as a regular object, so you have to do
  * it manually here. This is because Next.js evaluates this at build time,
  * and only used environment variables are included in the build.
  * @type {{ [k in keyof z.infer<typeof clientSchema>]: z.infer<typeof clientSchema>[k] | undefined }}