From 3ca1f551afb3db0327c0e07c6a6505850862375a Mon Sep 17 00:00:00 2001 From: Ahmed Elsakaan Date: Mon, 8 Apr 2024 22:44:00 +0100 Subject: [PATCH] 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