Skip to content

Commit

Permalink
refactor: Migrate to vercel url rewrites (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
JMBeresford committed Aug 9, 2023
1 parent c30e969 commit 9416920
Show file tree
Hide file tree
Showing 109 changed files with 640 additions and 554 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/deploy-experiments-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Vercel Preview Deployment
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
TURBO_TOKEN: ${{ secrets.VERCEL_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
on:
push:
branches-ignore:
- main
jobs:
Generate-Matrix:
runs-on: ubuntu-latest
outputs:
project-matrix: ${{ steps.set-project-ids.outputs.project-matrix }}
steps:
- name: Extract Matrix
id: set-project-ids
run: |
echo "project-matrix=$(echo '${{ vars.PROJECT_IDS }}' | jq -r 'keys' | tr -d ' \n\t\r')" >> "$GITHUB_OUTPUT"
Deploy-Preview:
needs: [Generate-Matrix]
strategy:
matrix:
experiment: ${{ fromJson(needs.Generate-Matrix.outputs.project-matrix) }}
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2
- uses: actions/setup-node@v3
with:
node-version: 18

- uses: pnpm/action-setup@v2
with:
version: 8

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-${{ matrix.experiment }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-${{ matrix.experiment }}-pnpm-store-
- name: Extract Project ID
id: set-project-id
run: |
echo "PROJECT_ID=$(echo '${{ vars.PROJECT_IDS }}' | jq '."${{ matrix.experiment }}"')" >> $GITHUB_ENV
- name: Set Project ID as Environment Variable
run: echo "VERCEL_PROJECT_ID=${{ fromJson(env.PROJECT_ID) }}" >> $GITHUB_ENV

- name: Install dependencies
run: pnpm install

- name: Check For Changes
id: check-for-changes
continue-on-error: true
run: |
pnpm dlx turbo-ignore ${{ matrix.experiment }} --task=build
- name: Build and Deploy
if: steps.check-for-changes.outcome == 'failure'
run: |
pnpm install --global vercel@latest
vercel pull --environment=preview -t ${{ secrets.VERCEL_TOKEN }} -y
vercel build -A experiments/${{ matrix.experiment }}/vercel.json -t ${{ secrets.VERCEL_TOKEN }} -y
vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
76 changes: 76 additions & 0 deletions .github/workflows/deploy-experiments-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Vercel Production Deployment
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
TURBO_TOKEN: ${{ secrets.VERCEL_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
on:
push:
branches:
- main
jobs:
Generate-Matrix:
runs-on: ubuntu-latest
outputs:
project-matrix: ${{ steps.set-project-ids.outputs.project-matrix }}
steps:
- name: Extract Matrix
id: set-project-ids
run: |
echo "project-matrix=$(echo '${{ vars.PROJECT_IDS }}' | jq -r 'keys' | tr -d ' \n\t\r')" >> "$GITHUB_OUTPUT"
Deploy-Preview:
needs: [Generate-Matrix]
strategy:
matrix:
experiment: ${{ fromJson(needs.Generate-Matrix.outputs.project-matrix) }}
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2
- uses: actions/setup-node@v3
with:
node-version: 18

- uses: pnpm/action-setup@v2
with:
version: 8

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-${{ matrix.experiment }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-${{ matrix.experiment }}-pnpm-store-
- name: Extract Project ID
id: set-project-id
run: |
echo "PROJECT_ID=$(echo '${{ vars.PROJECT_IDS }}' | jq '."${{ matrix.experiment }}"')" >> $GITHUB_ENV
- name: Set Project ID as Environment Variable
run: echo "VERCEL_PROJECT_ID=${{ fromJson(env.PROJECT_ID) }}" >> $GITHUB_ENV

- name: Install dependencies
run: pnpm install

- name: Check For Changes
id: check-for-changes
continue-on-error: true
run: |
pnpm dlx turbo-ignore ${{ matrix.experiment }} --task=build
- name: Build and Deploy
if: steps.check-for-changes.outcome == 'failure'
run: |
pnpm install --global vercel@latest
vercel pull --environment=production -t ${{ secrets.VERCEL_TOKEN }} -y
vercel build -A experiments/${{ matrix.experiment }}/vercel.json -t ${{ secrets.VERCEL_TOKEN }} -y --prod
vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ node_modules

# testing
coverage
.vars

# next.js
.next/
Expand Down
4 changes: 4 additions & 0 deletions apps/lab/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module.exports = {
root: true,
extends: ["plugin:custom/next"],
rules: {
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-namespace": "off",
},
};
15 changes: 0 additions & 15 deletions apps/lab/app/experiments/ChaosSphere/Experiment.tsx

This file was deleted.

12 changes: 0 additions & 12 deletions apps/lab/app/experiments/ChaosSphere/page.tsx

This file was deleted.

15 changes: 0 additions & 15 deletions apps/lab/app/experiments/CosmicPlatform/Experiment.tsx

This file was deleted.

12 changes: 0 additions & 12 deletions apps/lab/app/experiments/CosmicPlatform/page.tsx

This file was deleted.

18 changes: 0 additions & 18 deletions apps/lab/app/experiments/ExtraDimensionalInputForm/Experiment.tsx

This file was deleted.

12 changes: 0 additions & 12 deletions apps/lab/app/experiments/ExtraDimensionalInputForm/page.tsx

This file was deleted.

15 changes: 0 additions & 15 deletions apps/lab/app/experiments/Metaballs/Experiment.tsx

This file was deleted.

16 changes: 0 additions & 16 deletions apps/lab/app/experiments/Metaballs/page.tsx

This file was deleted.

15 changes: 0 additions & 15 deletions apps/lab/app/experiments/OceanicHorizon/Experiment.tsx

This file was deleted.

12 changes: 0 additions & 12 deletions apps/lab/app/experiments/OceanicHorizon/page.tsx

This file was deleted.

16 changes: 0 additions & 16 deletions apps/lab/app/experiments/RetroGaming/Experiment.tsx

This file was deleted.

12 changes: 0 additions & 12 deletions apps/lab/app/experiments/RetroGaming/page.tsx

This file was deleted.

15 changes: 0 additions & 15 deletions apps/lab/app/experiments/SRankJutsu/Experiment.tsx

This file was deleted.

12 changes: 0 additions & 12 deletions apps/lab/app/experiments/SRankJutsu/page.tsx

This file was deleted.

15 changes: 0 additions & 15 deletions apps/lab/app/experiments/Skywalker/Experiment.tsx

This file was deleted.

Loading

1 comment on commit 9416920

@vercel
Copy link

@vercel vercel bot commented on 9416920 Aug 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.