From 7964bd906cb64185a040611685db9f04bc76050f Mon Sep 17 00:00:00 2001 From: Ahmed Elsakaan Date: Sun, 7 Apr 2024 23:12:33 +0100 Subject: [PATCH 01/23] feat: initialise work on gh actions for repo --- .github/workflows/ci.yml | 61 +++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 7 ++-- 2 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..3fbf98be --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,61 @@ +name: CI + +on: + push: + branches: ['main'] + pull_request: + types: [opened, synchronize] + +jobs: + code-quality: + name: Code Quality Checks + timeout-minutes: 15 + runs-on: ubuntu-latest + env: + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + TURBO_TEAM: ${{ vars.TURBO_TEAM }} + + steps: + - name: Check out code + uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: setup volta + uses: volta-cli/action@v4 + + - name: install pnpm + uses: pnpm/action-setup@v3 + with: + run_install: false + + - name: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - uses: actions/cache@v4 + name: Setup pnpm cache + with: + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: install dependencies + run: pnpm install --frozen-lockfile + + - name: format + run: pnpm run format:check + + - name: lint spellcheck + run: pnpm run lint:spell + + - name: lint markdown + run: pnpm run lint:md + + - name: lint code + run: pnpm turbo lint + + - name: typecheck + run: pnpm turbo typecheck diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e8f176da..3c8406c9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,14 +14,12 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout code repository - # https://github.com/actions/checkout uses: actions/checkout@v4 with: fetch-depth: 0 - - name: setup node.js - # https://github.com/actions/setup-node - uses: actions/setup-node@v4 + - name: setup volta + uses: volta-cli/action@v4 - name: install pnpm uses: pnpm/action-setup@v3 @@ -45,7 +43,6 @@ jobs: run: pnpm install --frozen-lockfile - name: create and publish versions - # https://github.com/changesets/action uses: changesets/action@v1 with: commit: 'chore: update versions' From c203ca424f3207e244b6fe083f4c07ceb9d6290f Mon Sep 17 00:00:00 2001 From: Ahmed Elsakaan Date: Sun, 7 Apr 2024 23:16:52 +0100 Subject: [PATCH 02/23] fix: lint spell --- .github/workflows/ci.yml | 3 +++ cspell.config.yaml | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3fbf98be..fbd097ce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,6 +24,9 @@ jobs: - name: setup volta uses: volta-cli/action@v4 + - name: get node version + run: node --version + - name: install pnpm uses: pnpm/action-setup@v3 with: diff --git a/cspell.config.yaml b/cspell.config.yaml index 2c0dea3e..4a5c86e8 100644 --- a/cspell.config.yaml +++ b/cspell.config.yaml @@ -6,6 +6,10 @@ ignorePaths: - .tsbuildinfo - .gitignore - dist + - storybook-static + - .next + - .astro + - drizzle words: - acst - aest @@ -64,3 +68,7 @@ words: - WITA - ixahmedxi - degit + - tada + - branchname + - codespaces + - codespace From 646b3e7a005640b230f551bba735f190bc7ce351 Mon Sep 17 00:00:00 2001 From: Ahmed Elsakaan Date: Sun, 7 Apr 2024 23:51:35 +0100 Subject: [PATCH 03/23] fix: rename auth env vars to start with AUTH_ --- apps/web/.env.example | 10 +++++----- packages/auth/src/providers/github.ts | 2 +- packages/auth/src/providers/google.ts | 8 ++++---- packages/env/src/web/server.ts | 20 ++++++++++---------- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/apps/web/.env.example b/apps/web/.env.example index 7e3c30dd..bf7f9d68 100644 --- a/apps/web/.env.example +++ b/apps/web/.env.example @@ -5,9 +5,9 @@ UPLOADTHING_APP_ID= UNKEY_ROOT_KEY= -GITHUB_ID= -GITHUB_SECRET= +AUTH_GITHUB_ID= +AUTH_GITHUB_SECRET= -GOOGLE_ID= -GOOGLE_SECRET= -GOOGLE_CODE_VERIFIER= \ No newline at end of file +AUTH_GOOGLE_ID= +AUTH_GOOGLE_SECRET= +AUTH_GOOGLE_CODE_VERIFIER= \ No newline at end of file diff --git a/packages/auth/src/providers/github.ts b/packages/auth/src/providers/github.ts index 0cd719b6..62a0c682 100644 --- a/packages/auth/src/providers/github.ts +++ b/packages/auth/src/providers/github.ts @@ -9,7 +9,7 @@ import { env } from '@orbitkit/env/web/server'; import { lucia } from '../lucia'; -const github = new GitHub(env.GITHUB_ID, env.GITHUB_SECRET); +const github = new GitHub(env.AUTH_GITHUB_ID, env.AUTH_GITHUB_SECRET); export async function createGithubAuthorizationURL(): Promise { const state = generateState(); diff --git a/packages/auth/src/providers/google.ts b/packages/auth/src/providers/google.ts index efdf5b1f..1c94e197 100644 --- a/packages/auth/src/providers/google.ts +++ b/packages/auth/src/providers/google.ts @@ -14,8 +14,8 @@ import { lucia } from '../lucia'; const baseUrl = getBaseUrl(); const google = new Google( - env.GOOGLE_ID, - env.GOOGLE_SECRET, + env.AUTH_GOOGLE_ID, + env.AUTH_GOOGLE_SECRET, `${baseUrl}/login/google/callback`, ); @@ -23,7 +23,7 @@ export async function createGoogleAuthorizationURL(): Promise { const state = generateState(); const url = await google.createAuthorizationURL( state, - env.GOOGLE_CODE_VERIFIER, + env.AUTH_GOOGLE_CODE_VERIFIER, { scopes: ['profile', 'email'], }, @@ -63,7 +63,7 @@ export async function validateGoogleCallback( try { const tokens = await google.validateAuthorizationCode( code, - env.GOOGLE_CODE_VERIFIER, + env.AUTH_GOOGLE_CODE_VERIFIER, ); const googleUserResponse = await fetch( 'https://openidconnect.googleapis.com/v1/userinfo', diff --git a/packages/env/src/web/server.ts b/packages/env/src/web/server.ts index ccd0be9a..5d5d73ce 100644 --- a/packages/env/src/web/server.ts +++ b/packages/env/src/web/server.ts @@ -15,12 +15,12 @@ export const env = createEnv({ UNKEY_ROOT_KEY: z.string().optional(), - GITHUB_ID: z.string(), - GITHUB_SECRET: z.string(), + AUTH_GITHUB_ID: z.string(), + AUTH_GITHUB_SECRET: z.string(), - GOOGLE_ID: z.string(), - GOOGLE_SECRET: z.string(), - GOOGLE_CODE_VERIFIER: z.string(), + AUTH_GOOGLE_ID: z.string(), + AUTH_GOOGLE_SECRET: z.string(), + AUTH_GOOGLE_CODE_VERIFIER: z.string(), }, runtimeEnv: { NODE_ENV: process.env['NODE_ENV'], @@ -33,12 +33,12 @@ export const env = createEnv({ UNKEY_ROOT_KEY: process.env['UNKEY_ROOT_KEY'], - GITHUB_ID: process.env['GITHUB_ID'], - GITHUB_SECRET: process.env['GITHUB_SECRET'], + AUTH_GITHUB_ID: process.env['AUTH_GITHUB_ID'], + AUTH_GITHUB_SECRET: process.env['AUTH_GITHUB_SECRET'], - GOOGLE_ID: process.env['GOOGLE_ID'], - GOOGLE_SECRET: process.env['GOOGLE_SECRET'], - GOOGLE_CODE_VERIFIER: process.env['GOOGLE_CODE_VERIFIER'], + AUTH_GOOGLE_ID: process.env['AUTH_GOOGLE_ID'], + AUTH_GOOGLE_SECRET: process.env['AUTH_GOOGLE_SECRET'], + AUTH_GOOGLE_CODE_VERIFIER: process.env['AUTH_GOOGLE_CODE_VERIFIER'], }, emptyStringAsUndefined: true, skipValidation: !!process.env['SKIP_ENV_VALIDATION'], From d2bfafb3bc291b96fddfeaa41f455dd884129df0 Mon Sep 17 00:00:00 2001 From: Ahmed Elsakaan Date: Sun, 7 Apr 2024 23:55:01 +0100 Subject: [PATCH 04/23] fix: expose env vars to gh action --- .github/workflows/ci.yml | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fbd097ce..6bf19680 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,14 +6,30 @@ on: pull_request: types: [opened, synchronize] +env: + # Turborepo + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + TURBO_TEAM: ${{ vars.TURBO_TEAM }} + + # Authentication + AUTH_GITHUB_ID: ${{ secrets.AUTH_GITHUB_ID }} + AUTH_GITHUB_SECRET: ${{ secrets.AUTH_GITHUB_SECRET }} + AUTH_GOOGLE_ID: ${{ secrets.AUTH_GOOGLE_ID }} + AUTH_GOOGLE_SECRET: ${{ secrets.AUTH_GOOGLE_SECRET }} + AUTH_GOOGLE_CODE_VERIFIER: ${{ secrets.AUTH_GOOGLE_CODE_VERIFIER }} + + # Uploadthing + UPLOADTHING_SECRET: ${{ secrets.UPLOADTHING_SECRET }} + UPLOADTHING_APP_ID: ${{ secrets.UPLOADTHING_APP_ID }} + + # Unkey + UNKEY_ROOT_KEY: ${{ secrets.UNKEY_ROOT_KEY }} + jobs: code-quality: name: Code Quality Checks timeout-minutes: 15 runs-on: ubuntu-latest - env: - TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} - TURBO_TEAM: ${{ vars.TURBO_TEAM }} steps: - name: Check out code From 943d242b6e03550ebbf0320b903a5e25824aee4f Mon Sep 17 00:00:00 2001 From: Ahmed Elsakaan Date: Mon, 8 Apr 2024 21:39:54 +0100 Subject: [PATCH 05/23] feat: trying out neon create db branch workflow --- .github/workflows/ci.yml | 7 ++--- .github/workflows/pr-db-branch.yml | 42 ++++++++++++++++++++++++++++++ cspell.config.yaml | 2 ++ 3 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/pr-db-branch.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6bf19680..221ff879 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -73,8 +73,5 @@ jobs: - name: lint markdown run: pnpm run lint:md - - name: lint code - run: pnpm turbo lint - - - name: typecheck - run: pnpm turbo typecheck + - name: lint & typecheck + run: pnpm turbo lint typecheck diff --git a/.github/workflows/pr-db-branch.yml b/.github/workflows/pr-db-branch.yml new file mode 100644 index 00000000..be8190c2 --- /dev/null +++ b/.github/workflows/pr-db-branch.yml @@ -0,0 +1,42 @@ +name: Pull Request Database Branch +on: [pull_request] + +env: + NEON_DATABASE_USERNAME: ${{ secrets.NEON_DATABASE_USERNAME }} + NEON_API_KEY: ${{ secrets.NEON_API_KEY }} + NEON_PROJECT_ID: ${{ secrets.NEON_PROJECT_ID }} + +jobs: + create-db-branch: + runs-on: ubuntu-latest + + concurrency: + group: pr-${{ github.event.number }} + + steps: + - name: Get branch name + id: branch_name + uses: tj-actions/branch-names@v8 + + - name: Create Neon Branch + id: create-branch + uses: neondatabase/create-branch-action@v4 + with: + project_id: ${{ env.NEON_PROJECT_ID }} + branch_name: pr-${{ github.event.number}}-${{ steps.branch_name.outputs.current_branch }} + username: ${{ env.NEON_DATABASE_USERNAME }} + api_key: ${{ env.NEON_API_KEY }} + + - name: Run schema migrations + run: | + touch .env + + echo DATABASE_URL=${{ steps.create-branch.outputs.db_url }}?sslmode=require >> .env + + pnpm turbo db:migrate + + - name: Comment on Pull Request + uses: thollander/actions-comment-pull-request@v2 + with: + message: | + Neon branch :elephant: : https://console.neon.tech/app/projects/${{ secrets.NEON_PROJECT_ID }}/branches/${{ steps.create-branch.outputs.branch_id }} diff --git a/cspell.config.yaml b/cspell.config.yaml index 4a5c86e8..3d14cbb6 100644 --- a/cspell.config.yaml +++ b/cspell.config.yaml @@ -72,3 +72,5 @@ words: - branchname - codespaces - codespace + - sslmode + - thollander From b50d1ffe8f516b4ed92e683c116e473b1cbb5695 Mon Sep 17 00:00:00 2001 From: Ahmed Elsakaan Date: Mon, 8 Apr 2024 21:41:24 +0100 Subject: [PATCH 06/23] fix: neon create action pnpm --- .github/workflows/pr-db-branch.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.github/workflows/pr-db-branch.yml b/.github/workflows/pr-db-branch.yml index be8190c2..6be5f0f0 100644 --- a/.github/workflows/pr-db-branch.yml +++ b/.github/workflows/pr-db-branch.yml @@ -14,6 +14,35 @@ jobs: group: pr-${{ github.event.number }} steps: + - name: Check out code + uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: setup volta + uses: volta-cli/action@v4 + + - name: install pnpm + uses: pnpm/action-setup@v3 + with: + run_install: false + + - name: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - uses: actions/cache@v4 + name: Setup pnpm cache + with: + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: install dependencies + run: pnpm install --frozen-lockfile + - name: Get branch name id: branch_name uses: tj-actions/branch-names@v8 From 08bf7d8ce635239e765601b3683b9595664ca5cd Mon Sep 17 00:00:00 2001 From: Ahmed Elsakaan Date: Mon, 8 Apr 2024 21:43:36 +0100 Subject: [PATCH 07/23] trying --- .github/workflows/pr-db-branch.yml | 32 +++++++++--------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/.github/workflows/pr-db-branch.yml b/.github/workflows/pr-db-branch.yml index 6be5f0f0..0cb7bb72 100644 --- a/.github/workflows/pr-db-branch.yml +++ b/.github/workflows/pr-db-branch.yml @@ -14,34 +14,20 @@ jobs: group: pr-${{ github.event.number }} steps: - - name: Check out code - uses: actions/checkout@v4 - with: - fetch-depth: 2 - - - name: setup volta - uses: volta-cli/action@v4 + - uses: actions/checkout@v4 - - name: install pnpm - uses: pnpm/action-setup@v3 + - uses: pnpm/action-setup@v2 with: - run_install: false - - - name: Get pnpm store directory - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + version: 8 - - uses: actions/cache@v4 - name: Setup pnpm cache + - name: Use Node.js 20 + uses: actions/setup-node@v4 with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- + node-version: 20 + cache: 'pnpm' - - name: install dependencies - run: pnpm install --frozen-lockfile + - name: Install dependencies + run: pnpm install - name: Get branch name id: branch_name From a1a715169615f83dc71cac088befa12063e057e6 Mon Sep 17 00:00:00 2001 From: Ahmed Elsakaan Date: Mon, 8 Apr 2024 21:46:12 +0100 Subject: [PATCH 08/23] trying --- .github/workflows/pr-db-branch.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr-db-branch.yml b/.github/workflows/pr-db-branch.yml index 0cb7bb72..b02e5eb7 100644 --- a/.github/workflows/pr-db-branch.yml +++ b/.github/workflows/pr-db-branch.yml @@ -6,6 +6,14 @@ env: NEON_API_KEY: ${{ secrets.NEON_API_KEY }} NEON_PROJECT_ID: ${{ secrets.NEON_PROJECT_ID }} + UPLOADTHING_APP_ID: ${{ secrets.UPLOADTHING_APP_ID }} + UPLOADTHING_SECRET: ${{ secrets.UPLOADTHING_SECRET }} + AUTH_GITHUB_ID: ${{ secrets.AUTH_GITHUB_ID }} + AUTH_GITHUB_SECRET: ${{ secrets.AUTH_GITHUB_SECRET }} + AUTH_GOOGLE_ID: ${{ secrets.AUTH_GOOGLE_ID }} + AUTH_GOOGLE_SECRET: ${{ secrets.AUTH_GOOGLE_SECRET }} + AUTH_GOOGLE_CODE_VERIFIER: ${{ secrets.AUTH_GOOGLE_CODE_VERIFIER }} + jobs: create-db-branch: runs-on: ubuntu-latest @@ -44,7 +52,7 @@ jobs: - name: Run schema migrations run: | - touch .env + touch apps/web/.env.local echo DATABASE_URL=${{ steps.create-branch.outputs.db_url }}?sslmode=require >> .env From 05e1c8f99162a676c9720855cd9d491f4adf27ad Mon Sep 17 00:00:00 2001 From: Ahmed Elsakaan Date: Mon, 8 Apr 2024 21:46:24 +0100 Subject: [PATCH 09/23] trying --- .github/workflows/pr-db-branch.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-db-branch.yml b/.github/workflows/pr-db-branch.yml index b02e5eb7..68a0dd88 100644 --- a/.github/workflows/pr-db-branch.yml +++ b/.github/workflows/pr-db-branch.yml @@ -52,7 +52,7 @@ jobs: - name: Run schema migrations run: | - touch apps/web/.env.local + touch ./apps/web/.env.local echo DATABASE_URL=${{ steps.create-branch.outputs.db_url }}?sslmode=require >> .env From 5c8c7557e7c447353a8b3b9203f4ba9c900cd7e7 Mon Sep 17 00:00:00 2001 From: Ahmed Elsakaan Date: Mon, 8 Apr 2024 21:50:34 +0100 Subject: [PATCH 10/23] trying --- .github/workflows/pr-db-branch.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-db-branch.yml b/.github/workflows/pr-db-branch.yml index 68a0dd88..b62dbae1 100644 --- a/.github/workflows/pr-db-branch.yml +++ b/.github/workflows/pr-db-branch.yml @@ -52,7 +52,7 @@ jobs: - name: Run schema migrations run: | - touch ./apps/web/.env.local + touch ./packages/db/.env echo DATABASE_URL=${{ steps.create-branch.outputs.db_url }}?sslmode=require >> .env From cfd0defcf6bc11708a3ad494d549d4c9b5900b35 Mon Sep 17 00:00:00 2001 From: Ahmed Elsakaan Date: Mon, 8 Apr 2024 21:51:55 +0100 Subject: [PATCH 11/23] trying --- .github/workflows/pr-db-branch.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-db-branch.yml b/.github/workflows/pr-db-branch.yml index b62dbae1..e4198071 100644 --- a/.github/workflows/pr-db-branch.yml +++ b/.github/workflows/pr-db-branch.yml @@ -52,9 +52,9 @@ jobs: - name: Run schema migrations run: | - touch ./packages/db/.env + touch ./apps/web/.env - echo DATABASE_URL=${{ steps.create-branch.outputs.db_url }}?sslmode=require >> .env + echo DATABASE_URL=${{ steps.create-branch.outputs.db_url }}?sslmode=require >> ./apps/web/.env pnpm turbo db:migrate From 79e00f5d2e09441c90e5303578ad82099c567a3e Mon Sep 17 00:00:00 2001 From: Ahmed Elsakaan Date: Mon, 8 Apr 2024 21:54:58 +0100 Subject: [PATCH 12/23] trying --- .github/workflows/pr-db-branch.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pr-db-branch.yml b/.github/workflows/pr-db-branch.yml index e4198071..9bbe27c6 100644 --- a/.github/workflows/pr-db-branch.yml +++ b/.github/workflows/pr-db-branch.yml @@ -51,12 +51,9 @@ jobs: api_key: ${{ env.NEON_API_KEY }} - name: Run schema migrations - run: | - touch ./apps/web/.env - - echo DATABASE_URL=${{ steps.create-branch.outputs.db_url }}?sslmode=require >> ./apps/web/.env - - pnpm turbo db:migrate + env: + DATABASE_URL: '${{ steps.create-branch.outputs.db_url }}?sslmode=require' + run: pnpm turbo db:migrate - name: Comment on Pull Request uses: thollander/actions-comment-pull-request@v2 From 31f6888df3ecb6b3c5df71fbae2d4943bc2839a1 Mon Sep 17 00:00:00 2001 From: Ahmed Elsakaan Date: Mon, 8 Apr 2024 21:57:41 +0100 Subject: [PATCH 13/23] fix: adds github token to create-db-branch workflow --- .github/workflows/pr-db-branch.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pr-db-branch.yml b/.github/workflows/pr-db-branch.yml index 9bbe27c6..e0ae6458 100644 --- a/.github/workflows/pr-db-branch.yml +++ b/.github/workflows/pr-db-branch.yml @@ -14,6 +14,8 @@ env: AUTH_GOOGLE_SECRET: ${{ secrets.AUTH_GOOGLE_SECRET }} AUTH_GOOGLE_CODE_VERIFIER: ${{ secrets.AUTH_GOOGLE_CODE_VERIFIER }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + jobs: create-db-branch: runs-on: ubuntu-latest From 0170cec6bcaa5e35ac078e694d795f98b24cb5c4 Mon Sep 17 00:00:00 2001 From: Ahmed Elsakaan Date: Mon, 8 Apr 2024 22:00:47 +0100 Subject: [PATCH 14/23] fix: adds write permissiong to pr-db-branch workflow --- .github/workflows/pr-db-branch.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/pr-db-branch.yml b/.github/workflows/pr-db-branch.yml index e0ae6458..fe76126f 100644 --- a/.github/workflows/pr-db-branch.yml +++ b/.github/workflows/pr-db-branch.yml @@ -1,6 +1,9 @@ name: Pull Request Database Branch on: [pull_request] +permissions: + pull-requests: write + env: NEON_DATABASE_USERNAME: ${{ secrets.NEON_DATABASE_USERNAME }} NEON_API_KEY: ${{ secrets.NEON_API_KEY }} From 413c06223a7b7f202e0d3c838747bc65c53cf447 Mon Sep 17 00:00:00 2001 From: Ahmed Elsakaan Date: Mon, 8 Apr 2024 22:30:16 +0100 Subject: [PATCH 15/23] get back pnpm with cache stuff --- .github/workflows/pr-db-branch.yml | 42 +++++++++++++++++------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/.github/workflows/pr-db-branch.yml b/.github/workflows/pr-db-branch.yml index fe76126f..cc21673d 100644 --- a/.github/workflows/pr-db-branch.yml +++ b/.github/workflows/pr-db-branch.yml @@ -9,15 +9,7 @@ env: NEON_API_KEY: ${{ secrets.NEON_API_KEY }} NEON_PROJECT_ID: ${{ secrets.NEON_PROJECT_ID }} - UPLOADTHING_APP_ID: ${{ secrets.UPLOADTHING_APP_ID }} - UPLOADTHING_SECRET: ${{ secrets.UPLOADTHING_SECRET }} - AUTH_GITHUB_ID: ${{ secrets.AUTH_GITHUB_ID }} - AUTH_GITHUB_SECRET: ${{ secrets.AUTH_GITHUB_SECRET }} - AUTH_GOOGLE_ID: ${{ secrets.AUTH_GOOGLE_ID }} - AUTH_GOOGLE_SECRET: ${{ secrets.AUTH_GOOGLE_SECRET }} - AUTH_GOOGLE_CODE_VERIFIER: ${{ secrets.AUTH_GOOGLE_CODE_VERIFIER }} - - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SKIP_ENV_VALIDATION: true jobs: create-db-branch: @@ -27,20 +19,34 @@ jobs: group: pr-${{ github.event.number }} steps: - - uses: actions/checkout@v4 + - name: checkout code repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 - - uses: pnpm/action-setup@v2 + - name: setup volta + uses: volta-cli/action@v4 + + - name: install pnpm + uses: pnpm/action-setup@v3 with: - version: 8 + run_install: false + + - name: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - name: Use Node.js 20 - uses: actions/setup-node@v4 + - uses: actions/cache@v4 + name: Setup pnpm cache with: - node-version: 20 - cache: 'pnpm' + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- - - name: Install dependencies - run: pnpm install + - name: install dependencies + run: pnpm install --frozen-lockfile - name: Get branch name id: branch_name From 3ca1f551afb3db0327c0e07c6a6505850862375a Mon Sep 17 00:00:00 2001 From: Ahmed Elsakaan Date: Mon, 8 Apr 2024 22:44:00 +0100 Subject: [PATCH 16/23] let's see if that works --- .github/workflows/ci.yml | 195 +++++++++++++++++++++-------- .github/workflows/pr-db-branch.yml | 73 ----------- .github/workflows/release.yml | 32 ++--- 3 files changed, 156 insertions(+), 144 deletions(-) delete mode 100644 .github/workflows/pr-db-branch.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 221ff879..c0b978f4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,77 +1,174 @@ -name: CI +name: Pull Request Database Branch +on: [pull_request] -on: - push: - branches: ['main'] - pull_request: - types: [opened, synchronize] +permissions: + pull-requests: write env: # Turborepo TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} TURBO_TEAM: ${{ vars.TURBO_TEAM }} - # Authentication - AUTH_GITHUB_ID: ${{ secrets.AUTH_GITHUB_ID }} - AUTH_GITHUB_SECRET: ${{ secrets.AUTH_GITHUB_SECRET }} - AUTH_GOOGLE_ID: ${{ secrets.AUTH_GOOGLE_ID }} - AUTH_GOOGLE_SECRET: ${{ secrets.AUTH_GOOGLE_SECRET }} - AUTH_GOOGLE_CODE_VERIFIER: ${{ secrets.AUTH_GOOGLE_CODE_VERIFIER }} +jobs: + create-db-branch: + runs-on: ubuntu-latest - # Uploadthing - UPLOADTHING_SECRET: ${{ secrets.UPLOADTHING_SECRET }} - UPLOADTHING_APP_ID: ${{ secrets.UPLOADTHING_APP_ID }} + concurrency: + group: pr-${{ github.event.number }} - # Unkey - UNKEY_ROOT_KEY: ${{ secrets.UNKEY_ROOT_KEY }} + outputs: + db_url: ${{ steps.create-branch.outputs.db_url }} -jobs: - code-quality: - name: Code Quality Checks - timeout-minutes: 15 - runs-on: ubuntu-latest + env: + # Neon + NEON_DATABASE_USERNAME: ${{ secrets.NEON_DATABASE_USERNAME }} + NEON_API_KEY: ${{ secrets.NEON_API_KEY }} + NEON_PROJECT_ID: ${{ secrets.NEON_PROJECT_ID }} steps: - - name: Check out code - uses: actions/checkout@v4 + - uses: actions/checkout@v4 with: fetch-depth: 2 - - name: setup volta - uses: volta-cli/action@v4 + - uses: pnpm/action-setup@v2 + with: + version: 8 + + - name: Use Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Get branch name + id: branch_name + uses: tj-actions/branch-names@v8 + + - name: Create Neon Branch + id: create-branch + uses: neondatabase/create-branch-action@v4 + with: + project_id: ${{ env.NEON_PROJECT_ID }} + branch_name: pr-${{ github.event.number}}-${{ steps.branch_name.outputs.current_branch }} + username: ${{ env.NEON_DATABASE_USERNAME }} + api_key: ${{ env.NEON_API_KEY }} + + - name: Run schema migrations + env: + DATABASE_URL: '${{ steps.create-branch.outputs.db_url }}?sslmode=require' + run: pnpm turbo db:migrate + + - name: Comment on Pull Request + uses: thollander/actions-comment-pull-request@v2 + with: + message: | + Neon branch :elephant: : https://console.neon.tech/app/projects/${{ secrets.NEON_PROJECT_ID }}/branches/${{ steps.create-branch.outputs.branch_id }} + + format-lint-typecheck: + name: Format, Lint & Typecheck + runs-on: ubuntu-latest - - name: get node version - run: node --version + env: + SKIP_ENV_VALIDATION: true - - name: install pnpm - uses: pnpm/action-setup@v3 + steps: + - uses: actions/checkout@v4 with: - run_install: false + fetch-depth: 2 - - name: Get pnpm store directory - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + - uses: pnpm/action-setup@v2 + with: + version: 8 - - uses: actions/cache@v4 - name: Setup pnpm cache + - name: Use Node.js 20 + uses: actions/setup-node@v4 with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- + node-version: 20 + cache: 'pnpm' - - name: install dependencies + - name: Install dependencies run: pnpm install --frozen-lockfile - - name: format - run: pnpm run format:check + - name: Format check + run: pnpm format:check - - name: lint spellcheck - run: pnpm run lint:spell + - name: Spell check + run: pnpm lint:spell - - name: lint markdown - run: pnpm run lint:md + - name: Lint markdown + run: pnpm lint:md - - name: lint & typecheck + - name: Lint & Typecheck run: pnpm turbo lint typecheck + + build-marketing: + name: Build marketing website + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - uses: pnpm/action-setup@v2 + with: + version: 8 + + - name: Use Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Build marketing website + run: pnpm turbo build --filter=marketing + + build-app: + name: Build web app + runs-on: ubuntu-latest + needs: create-db-branch + + env: + # Database URL + DATABASE_URL: '${{ needs.create-db-branch.outputs.db_url }}?sslmode=require' + + # Authentication + AUTH_GITHUB_ID: ${{ secrets.AUTH_GITHUB_ID }} + AUTH_GITHUB_SECRET: ${{ secrets.AUTH_GITHUB_SECRET }} + AUTH_GOOGLE_ID: ${{ secrets.AUTH_GOOGLE_ID }} + AUTH_GOOGLE_SECRET: ${{ secrets.AUTH_GOOGLE_SECRET }} + AUTH_GOOGLE_CODE_VERIFIER: ${{ secrets.AUTH_GOOGLE_CODE_VERIFIER }} + + # Uploadthing + UPLOADTHING_SECRET: ${{ secrets.UPLOADTHING_SECRET }} + UPLOADTHING_APP_ID: ${{ secrets.UPLOADTHING_APP_ID }} + + # Unkey + UNKEY_ROOT_KEY: ${{ secrets.UNKEY_ROOT_KEY }} + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - uses: pnpm/action-setup@v2 + with: + version: 8 + + - name: Use Node.js 20 + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Build + run: pnpm turbo build --filter=web diff --git a/.github/workflows/pr-db-branch.yml b/.github/workflows/pr-db-branch.yml deleted file mode 100644 index cc21673d..00000000 --- a/.github/workflows/pr-db-branch.yml +++ /dev/null @@ -1,73 +0,0 @@ -name: Pull Request Database Branch -on: [pull_request] - -permissions: - pull-requests: write - -env: - NEON_DATABASE_USERNAME: ${{ secrets.NEON_DATABASE_USERNAME }} - NEON_API_KEY: ${{ secrets.NEON_API_KEY }} - NEON_PROJECT_ID: ${{ secrets.NEON_PROJECT_ID }} - - SKIP_ENV_VALIDATION: true - -jobs: - create-db-branch: - runs-on: ubuntu-latest - - concurrency: - group: pr-${{ github.event.number }} - - steps: - - name: checkout code repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: setup volta - uses: volta-cli/action@v4 - - - name: install pnpm - uses: pnpm/action-setup@v3 - with: - run_install: false - - - name: Get pnpm store directory - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - - uses: actions/cache@v4 - name: Setup pnpm cache - with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: install dependencies - run: pnpm install --frozen-lockfile - - - name: Get branch name - id: branch_name - uses: tj-actions/branch-names@v8 - - - name: Create Neon Branch - id: create-branch - uses: neondatabase/create-branch-action@v4 - with: - project_id: ${{ env.NEON_PROJECT_ID }} - branch_name: pr-${{ github.event.number}}-${{ steps.branch_name.outputs.current_branch }} - username: ${{ env.NEON_DATABASE_USERNAME }} - api_key: ${{ env.NEON_API_KEY }} - - - name: Run schema migrations - env: - DATABASE_URL: '${{ steps.create-branch.outputs.db_url }}?sslmode=require' - run: pnpm turbo db:migrate - - - name: Comment on Pull Request - uses: thollander/actions-comment-pull-request@v2 - with: - message: | - Neon branch :elephant: : https://console.neon.tech/app/projects/${{ secrets.NEON_PROJECT_ID }}/branches/${{ steps.create-branch.outputs.branch_id }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3c8406c9..81cd857a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,34 +13,22 @@ jobs: timeout-minutes: 15 runs-on: ubuntu-latest steps: - - name: checkout code repository - uses: actions/checkout@v4 + - uses: actions/checkout@v4 with: - fetch-depth: 0 + fetch-depth: 2 - - name: setup volta - uses: volta-cli/action@v4 - - - name: install pnpm - uses: pnpm/action-setup@v3 + - uses: pnpm/action-setup@v2 with: - run_install: false - - - name: Get pnpm store directory - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + version: 8 - - uses: actions/cache@v4 - name: Setup pnpm cache + - name: Use Node.js 18 + uses: actions/setup-node@v4 with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- + node-version: 20 + cache: 'pnpm' - - name: install dependencies - run: pnpm install --frozen-lockfile + - name: Install dependencies + run: pnpm install - name: create and publish versions uses: changesets/action@v1 From 10406f1e737bc2f41f6db1f22275f5fe08993a2d Mon Sep 17 00:00:00 2001 From: Ahmed Elsakaan Date: Mon, 8 Apr 2024 22:45:56 +0100 Subject: [PATCH 17/23] skip env validation for create-db-branch job --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c0b978f4..fd74b12c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,6 +11,7 @@ env: jobs: create-db-branch: + name: Create Neon DB Branch runs-on: ubuntu-latest concurrency: @@ -25,6 +26,8 @@ jobs: NEON_API_KEY: ${{ secrets.NEON_API_KEY }} NEON_PROJECT_ID: ${{ secrets.NEON_PROJECT_ID }} + SKIP_ENV_VALIDATION: true + steps: - uses: actions/checkout@v4 with: From 907e57d5cf2879d608d17494a5c822747154129e Mon Sep 17 00:00:00 2001 From: Ahmed Elsakaan Date: Mon, 8 Apr 2024 22:46:47 +0100 Subject: [PATCH 18/23] rename ci workflow name --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fd74b12c..8c3b6dd2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: Pull Request Database Branch +name: Pull Request CI on: [pull_request] permissions: From 2ab8d9e115962a27fa8b76ecb8f60e9de19ce619 Mon Sep 17 00:00:00 2001 From: Ahmed Elsakaan Date: Mon, 8 Apr 2024 22:55:13 +0100 Subject: [PATCH 19/23] new strategy --- .github/workflows/ci.yml | 87 +++++++++++----------------------------- 1 file changed, 23 insertions(+), 64 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8c3b6dd2..cb87c975 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,75 +1,12 @@ name: Pull Request CI on: [pull_request] -permissions: - pull-requests: write - env: # Turborepo TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} TURBO_TEAM: ${{ vars.TURBO_TEAM }} jobs: - create-db-branch: - name: Create Neon DB Branch - runs-on: ubuntu-latest - - concurrency: - group: pr-${{ github.event.number }} - - outputs: - db_url: ${{ steps.create-branch.outputs.db_url }} - - env: - # Neon - NEON_DATABASE_USERNAME: ${{ secrets.NEON_DATABASE_USERNAME }} - NEON_API_KEY: ${{ secrets.NEON_API_KEY }} - NEON_PROJECT_ID: ${{ secrets.NEON_PROJECT_ID }} - - SKIP_ENV_VALIDATION: true - - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 2 - - - uses: pnpm/action-setup@v2 - with: - version: 8 - - - name: Use Node.js 20 - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: 'pnpm' - - - name: Install dependencies - run: pnpm install --frozen-lockfile - - - name: Get branch name - id: branch_name - uses: tj-actions/branch-names@v8 - - - name: Create Neon Branch - id: create-branch - uses: neondatabase/create-branch-action@v4 - with: - project_id: ${{ env.NEON_PROJECT_ID }} - branch_name: pr-${{ github.event.number}}-${{ steps.branch_name.outputs.current_branch }} - username: ${{ env.NEON_DATABASE_USERNAME }} - api_key: ${{ env.NEON_API_KEY }} - - - name: Run schema migrations - env: - DATABASE_URL: '${{ steps.create-branch.outputs.db_url }}?sslmode=require' - run: pnpm turbo db:migrate - - - name: Comment on Pull Request - uses: thollander/actions-comment-pull-request@v2 - with: - message: | - Neon branch :elephant: : https://console.neon.tech/app/projects/${{ secrets.NEON_PROJECT_ID }}/branches/${{ steps.create-branch.outputs.branch_id }} - format-lint-typecheck: name: Format, Lint & Typecheck runs-on: ubuntu-latest @@ -135,9 +72,16 @@ jobs: build-app: name: Build web app runs-on: ubuntu-latest - needs: create-db-branch + + concurrency: + group: pr-${{ github.event.number }} env: + # Neon + NEON_DATABASE_USERNAME: ${{ secrets.NEON_DATABASE_USERNAME }} + NEON_API_KEY: ${{ secrets.NEON_API_KEY }} + NEON_PROJECT_ID: ${{ secrets.NEON_PROJECT_ID }} + # Database URL DATABASE_URL: '${{ needs.create-db-branch.outputs.db_url }}?sslmode=require' @@ -173,5 +117,20 @@ jobs: - name: Install dependencies run: pnpm install --frozen-lockfile + - name: Get branch name + id: branch_name + uses: tj-actions/branch-names@v8 + + - name: Create Neon Branch + id: create-branch + uses: neondatabase/create-branch-action@v4 + with: + project_id: ${{ env.NEON_PROJECT_ID }} + branch_name: pr-${{ github.event.number}}-${{ steps.branch_name.outputs.current_branch }} + username: ${{ env.NEON_DATABASE_USERNAME }} + api_key: ${{ env.NEON_API_KEY }} + - name: Build + env: + DATABASE_URL: ${{ steps.create-branch.outputs.db_url }}?sslmode=require run: pnpm turbo build --filter=web From d35946ecd132ae30a9c2454807389b708d31e590 Mon Sep 17 00:00:00 2001 From: Ahmed Elsakaan Date: Mon, 8 Apr 2024 23:07:18 +0100 Subject: [PATCH 20/23] sprinkling some refinements --- .github/workflows/ci.yml | 83 +++++++++++++++++++++++++++++----------- 1 file changed, 61 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cb87c975..635821fb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,18 +19,32 @@ jobs: with: fetch-depth: 2 - - uses: pnpm/action-setup@v2 + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + + - uses: pnpm/action-setup@v3 + name: Install pnpm with: version: 8 + run_install: false - - name: Use Node.js 20 - uses: actions/setup-node@v4 + - name: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - uses: actions/cache@v4 + name: Setup pnpm cache with: - node-version: 20 - cache: 'pnpm' + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- - name: Install dependencies - run: pnpm install --frozen-lockfile + run: pnpm install - name: Format check run: pnpm format:check @@ -53,18 +67,32 @@ jobs: with: fetch-depth: 2 - - uses: pnpm/action-setup@v2 + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + + - uses: pnpm/action-setup@v3 + name: Install pnpm with: version: 8 + run_install: false - - name: Use Node.js 20 - uses: actions/setup-node@v4 + - name: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - uses: actions/cache@v4 + name: Setup pnpm cache with: - node-version: 20 - cache: 'pnpm' + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- - name: Install dependencies - run: pnpm install --frozen-lockfile + run: pnpm install - name: Build marketing website run: pnpm turbo build --filter=marketing @@ -82,9 +110,6 @@ jobs: NEON_API_KEY: ${{ secrets.NEON_API_KEY }} NEON_PROJECT_ID: ${{ secrets.NEON_PROJECT_ID }} - # Database URL - DATABASE_URL: '${{ needs.create-db-branch.outputs.db_url }}?sslmode=require' - # Authentication AUTH_GITHUB_ID: ${{ secrets.AUTH_GITHUB_ID }} AUTH_GITHUB_SECRET: ${{ secrets.AUTH_GITHUB_SECRET }} @@ -104,18 +129,32 @@ jobs: with: fetch-depth: 2 - - uses: pnpm/action-setup@v2 + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + + - uses: pnpm/action-setup@v3 + name: Install pnpm with: version: 8 + run_install: false - - name: Use Node.js 20 - uses: actions/setup-node@v4 + - name: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - uses: actions/cache@v4 + name: Setup pnpm cache with: - node-version: 20 - cache: 'pnpm' + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- - name: Install dependencies - run: pnpm install --frozen-lockfile + run: pnpm install - name: Get branch name id: branch_name @@ -132,5 +171,5 @@ jobs: - name: Build env: - DATABASE_URL: ${{ steps.create-branch.outputs.db_url }}?sslmode=require + DATABASE_URL: '${{ steps.create-branch.outputs.db_url }}?sslmode=require' run: pnpm turbo build --filter=web From a3be828bc1b3f8b036233d038b6e885c67ffdc20 Mon Sep 17 00:00:00 2001 From: Ahmed Elsakaan Date: Tue, 9 Apr 2024 07:25:09 +0100 Subject: [PATCH 21/23] endgame --- .github/actions/setup.yml | 37 +++++++++++++ .github/workflows/ci.yml | 106 +++++++------------------------------- 2 files changed, 56 insertions(+), 87 deletions(-) create mode 100644 .github/actions/setup.yml diff --git a/.github/actions/setup.yml b/.github/actions/setup.yml new file mode 100644 index 00000000..6b879738 --- /dev/null +++ b/.github/actions/setup.yml @@ -0,0 +1,37 @@ +name: 'Setup' +description: 'Common setup steps for Actions' + +runs: + using: composite + steps: + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + + - uses: pnpm/action-setup@v3 + name: Install pnpm + with: + version: 8 + run_install: false + + - name: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - uses: actions/cache@v4 + name: Setup pnpm cache + with: + path: ${{ env.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install Turborepo + shell: bash + run: pnpm add -g turbo + + - name: Install dependencies + shell: bash + run: pnpm install diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 635821fb..b7de93fa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,7 @@ name: Pull Request CI on: [pull_request] env: - # Turborepo + # This enabled remote task cachinc using Turborepo TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} TURBO_TEAM: ${{ vars.TURBO_TEAM }} @@ -12,6 +12,7 @@ jobs: runs-on: ubuntu-latest env: + # We don't need to validate the environment variables when we are checking the format, linting and typechecking SKIP_ENV_VALIDATION: true steps: @@ -19,32 +20,8 @@ jobs: with: fetch-depth: 2 - - name: Install Node.js - uses: actions/setup-node@v4 - with: - node-version: 20 - - - uses: pnpm/action-setup@v3 - name: Install pnpm - with: - version: 8 - run_install: false - - - name: Get pnpm store directory - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - - uses: actions/cache@v4 - name: Setup pnpm cache - with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: Install dependencies - run: pnpm install + - name: Setup + uses: ./.github/actions/setup.yml - name: Format check run: pnpm format:check @@ -56,7 +33,7 @@ jobs: run: pnpm lint:md - name: Lint & Typecheck - run: pnpm turbo lint typecheck + run: turbo lint typecheck build-marketing: name: Build marketing website @@ -67,43 +44,16 @@ jobs: with: fetch-depth: 2 - - name: Install Node.js - uses: actions/setup-node@v4 - with: - node-version: 20 - - - uses: pnpm/action-setup@v3 - name: Install pnpm - with: - version: 8 - run_install: false - - - name: Get pnpm store directory - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - - uses: actions/cache@v4 - name: Setup pnpm cache - with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: Install dependencies - run: pnpm install + - name: Setup + uses: ./.github/actions/setup.yml - name: Build marketing website - run: pnpm turbo build --filter=marketing + run: turbo build --filter=marketing build-app: name: Build web app runs-on: ubuntu-latest - concurrency: - group: pr-${{ github.event.number }} - env: # Neon NEON_DATABASE_USERNAME: ${{ secrets.NEON_DATABASE_USERNAME }} @@ -129,32 +79,8 @@ jobs: with: fetch-depth: 2 - - name: Install Node.js - uses: actions/setup-node@v4 - with: - node-version: 20 - - - uses: pnpm/action-setup@v3 - name: Install pnpm - with: - version: 8 - run_install: false - - - name: Get pnpm store directory - shell: bash - run: | - echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV - - - uses: actions/cache@v4 - name: Setup pnpm cache - with: - path: ${{ env.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: Install dependencies - run: pnpm install + - name: Setup + uses: ./.github/actions/setup.yml - name: Get branch name id: branch_name @@ -165,11 +91,17 @@ jobs: uses: neondatabase/create-branch-action@v4 with: project_id: ${{ env.NEON_PROJECT_ID }} - branch_name: pr-${{ github.event.number}}-${{ steps.branch_name.outputs.current_branch }} + branch_name: web/pr-${{ github.event.number}}-${{ steps.branch_name.outputs.current_branch }} username: ${{ env.NEON_DATABASE_USERNAME }} api_key: ${{ env.NEON_API_KEY }} + - name: Set DATABASE_URL + shell: bash + run: | + echo "DATABASE_URL=${{ steps.create-branch.outputs.db_url }}?sslmode=require" >> $GITHUB_ENV + - name: Build env: - DATABASE_URL: '${{ steps.create-branch.outputs.db_url }}?sslmode=require' - run: pnpm turbo build --filter=web + DATABASE_URL: ${{ env.DATABASE_URL }} + # The build command will also apply schema migrations on the created database branch + run: turbo build --filter=web From 405aee5b26e316f45a13501964edeb757412539b Mon Sep 17 00:00:00 2001 From: Ahmed Elsakaan Date: Tue, 9 Apr 2024 07:26:46 +0100 Subject: [PATCH 22/23] fix: put setup action in folder --- .github/actions/{setup.yml => setup/action.yml} | 0 .github/workflows/ci.yml | 8 ++++---- 2 files changed, 4 insertions(+), 4 deletions(-) rename .github/actions/{setup.yml => setup/action.yml} (100%) diff --git a/.github/actions/setup.yml b/.github/actions/setup/action.yml similarity index 100% rename from .github/actions/setup.yml rename to .github/actions/setup/action.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b7de93fa..4ee55bb8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,7 @@ name: Pull Request CI on: [pull_request] env: - # This enabled remote task cachinc using Turborepo + # This enabled remote task caching using Turborepo TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} TURBO_TEAM: ${{ vars.TURBO_TEAM }} @@ -21,7 +21,7 @@ jobs: fetch-depth: 2 - name: Setup - uses: ./.github/actions/setup.yml + uses: ./.github/actions/setup - name: Format check run: pnpm format:check @@ -45,7 +45,7 @@ jobs: fetch-depth: 2 - name: Setup - uses: ./.github/actions/setup.yml + uses: ./.github/actions/setup - name: Build marketing website run: turbo build --filter=marketing @@ -80,7 +80,7 @@ jobs: fetch-depth: 2 - name: Setup - uses: ./.github/actions/setup.yml + uses: ./.github/actions/setup - name: Get branch name id: branch_name From cf03f0f252f5bc68c2b6382c9757c12296dc2656 Mon Sep 17 00:00:00 2001 From: Ahmed Elsakaan Date: Tue, 9 Apr 2024 07:42:01 +0100 Subject: [PATCH 23/23] completing it --- .github/workflows/main-ci.yml | 89 +++++++++++++++++++++++++ .github/workflows/{ci.yml => pr-ci.yml} | 0 .github/workflows/pr-cleanup.yml | 15 +++++ .github/workflows/release.yml | 14 +--- 4 files changed, 106 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/main-ci.yml rename .github/workflows/{ci.yml => pr-ci.yml} (100%) create mode 100644 .github/workflows/pr-cleanup.yml diff --git a/.github/workflows/main-ci.yml b/.github/workflows/main-ci.yml new file mode 100644 index 00000000..1add0a4a --- /dev/null +++ b/.github/workflows/main-ci.yml @@ -0,0 +1,89 @@ +name: Main CI +on: + push: + branches: + - main + +env: + # This enabled remote task caching using Turborepo + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + TURBO_TEAM: ${{ vars.TURBO_TEAM }} + +jobs: + format-lint-typecheck: + name: Format, Lint & Typecheck + runs-on: ubuntu-latest + + env: + # We don't need to validate the environment variables when we are checking the format, linting and typechecking + SKIP_ENV_VALIDATION: true + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: Setup + uses: ./.github/actions/setup + + - name: Format check + run: pnpm format:check + + - name: Spell check + run: pnpm lint:spell + + - name: Lint markdown + run: pnpm lint:md + + - name: Lint & Typecheck + run: turbo lint typecheck + + build-marketing: + name: Build marketing website + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: Setup + uses: ./.github/actions/setup + + - name: Build marketing website + run: turbo build --filter=marketing + + build-app: + name: Build web app + runs-on: ubuntu-latest + + environment: Production + + env: + # Database URL + DATABASE_URL: ${{ secrets.DATABASE_URL }} + + # Authentication + AUTH_GITHUB_ID: ${{ secrets.AUTH_GITHUB_ID }} + AUTH_GITHUB_SECRET: ${{ secrets.AUTH_GITHUB_SECRET }} + AUTH_GOOGLE_ID: ${{ secrets.AUTH_GOOGLE_ID }} + AUTH_GOOGLE_SECRET: ${{ secrets.AUTH_GOOGLE_SECRET }} + AUTH_GOOGLE_CODE_VERIFIER: ${{ secrets.AUTH_GOOGLE_CODE_VERIFIER }} + + # Uploadthing + UPLOADTHING_SECRET: ${{ secrets.UPLOADTHING_SECRET }} + UPLOADTHING_APP_ID: ${{ secrets.UPLOADTHING_APP_ID }} + + # Unkey + UNKEY_ROOT_KEY: ${{ secrets.UNKEY_ROOT_KEY }} + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 2 + + - name: Setup + uses: ./.github/actions/setup + + - name: Build + run: turbo build --filter=web diff --git a/.github/workflows/ci.yml b/.github/workflows/pr-ci.yml similarity index 100% rename from .github/workflows/ci.yml rename to .github/workflows/pr-ci.yml diff --git a/.github/workflows/pr-cleanup.yml b/.github/workflows/pr-cleanup.yml new file mode 100644 index 00000000..d2269937 --- /dev/null +++ b/.github/workflows/pr-cleanup.yml @@ -0,0 +1,15 @@ +name: Clean up after Pull Request +on: + pull_request: + types: [closed] + +jobs: + delete-db-branch: + runs-on: ubuntu-latest + steps: + - name: Delete Neon Branch + uses: neondatabase/delete-branch-action@v3.1.3 + with: + project_id: ${{ secrets.NEON_PROJECT_ID }} + branch_name: web/pr-${{ github.event.number}}-${{ steps.branch_name.outputs.current_branch }} + api_key: ${{ secrets.NEON_API_KEY }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 81cd857a..1d6ec9f9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,18 +17,8 @@ jobs: with: fetch-depth: 2 - - uses: pnpm/action-setup@v2 - with: - version: 8 - - - name: Use Node.js 18 - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: 'pnpm' - - - name: Install dependencies - run: pnpm install + - name: Setup + uses: ./.github/actions/setup - name: create and publish versions uses: changesets/action@v1