Skip to content

Commit

Permalink
Merge pull request #119 from NUS-Project-SaBai/vercel-deployment
Browse files Browse the repository at this point in the history
testing vercel git hub actions
  • Loading branch information
davidgohzk authored Jul 18, 2024
2 parents 4f28555 + 21ee5dc commit 93ab75f
Show file tree
Hide file tree
Showing 8 changed files with 1,744 additions and 6 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/vercel-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: deploy
on:
pull_request:
branches:
- deployment
workflow_dispatch:
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm install -g pnpm
- run: pnpm install
- run: pnpm vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
- run: pnpm vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
- run: pnpm vercel deploy --prod --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
24 changes: 24 additions & 0 deletions .github/workflows/vercel-pr-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: preview
on:
pull_request:
workflow_dispatch:
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
jobs:
preview:
runs-on: ubuntu-latest
environment:
name: Preview
url: ${{ steps.deploy.outputs.url }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm install -g pnpm
- run: pnpm install
- run: pnpm vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
- run: pnpm vercel build --token=${{ secrets.VERCEL_TOKEN }}
- id: deploy
run: echo "::set-output name=url::$(pnpm vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }})"
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"lint-staged": "^15.2.7",
"postcss": "^8.4.33",
"prettier": "^3.3.2",
"tailwindcss": "^3.4.1"
"tailwindcss": "^3.4.1",
"vercel": "^35.0.3"
},
"lint-staged": {
"*.{js,ts,json,css,scss,md}": [
Expand Down
4 changes: 4 additions & 0 deletions pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import '@/styles/globals.css';

Modal.setAppElement('#__next');

// Set to VERCEL_URL or override with AUTH0_BASE_URL
process.env.AUTH0_BASE_URL =
process.env.AUTH0_BASE_URL || process.env.VERCEL_URL;

const MyApp = ({ Component, pageProps }) => {
return (
<UserProvider>
Expand Down
4 changes: 4 additions & 0 deletions pages/api/auth/[auth0].js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// Set to VERCEL_URL or override with AUTH0_BASE_URL
process.env.AUTH0_BASE_URL =
process.env.AUTH0_BASE_URL || process.env.VERCEL_URL;

import { handleAuth } from '@auth0/nextjs-auth0';

export default handleAuth();
Loading

0 comments on commit 93ab75f

Please sign in to comment.