Skip to content

Commit

Permalink
Github actions to create dist in server
Browse files Browse the repository at this point in the history
  • Loading branch information
karlosvas committed Jan 12, 2025
1 parent fb18f19 commit 9ac237b
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 26 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Deploy

on:
push:
branches:
- main

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: "lts/*"

- name: Install Vercel CLI
run: npm install -g vercel@latest

- name: Deploy server to Vercel
run: |
echo -e "\e[34mDeploying server to Vercel...\e[0m"
cd server
vercel link --yes --token=${{ secrets.VERCEL_TOKEN }}
vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
npm install
vercel build
vercel deploy --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy client to Vercel
run: |
echo -e "\e[34mDeploying client to Vercel...\e[0m"
cd client
vercel link --yes --token=${{ secrets.VERCEL_TOKEN }}
vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
npm install
npm run build
vercel deploy --token=${{ secrets.VERCEL_TOKEN }}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ dev
dist-ssr
client/dist
*.local
dist

# Editor directories and files
.vscode/*
Expand Down
1 change: 1 addition & 0 deletions client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vercel
7 changes: 0 additions & 7 deletions client/vercel.json

This file was deleted.

1 change: 1 addition & 0 deletions server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.vercel
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.ts",
"scripts": {
"start": "npm run build && node dist/index.js",
"dev": "node --loader ts-node/esm src/index.js",
"dev": "node --loader ts-node/esm index.js",
"test": "npm run build && playwright test",
"build": "tsc"
},
Expand Down
2 changes: 1 addition & 1 deletion server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"rootDir": "./" /* Specify the root folder within your source files. */,
"moduleResolution": "node" /* Specify how TypeScript looks up a file from a given module specifier. */,
"baseUrl": "./" /* Specify the base directory to resolve non-relative module names. */,
"outDir": "dist" /* Specify an output folder for all emitted files. */,
"outDir": "public" /* Specify an output folder for all emitted files. */,
"paths": {
"types/*": ["types/*"]
} /* Specify a set of entries that re-map imports to additional lookup locations. */,
Expand Down
16 changes: 0 additions & 16 deletions server/vercel.json

This file was deleted.

42 changes: 42 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"version": 2,
"projects": [
{
"name": "thefluentspanishhouse-server",
"builds": [
{
"src": "server/package.json",
"use": "@vercel/node"
}
]
},
{
"name": "thefluentspanishhouse-client",
"builds": [
{
"src": "client/package.json",
"use": "@vercel/static-build",
"config": {
"distDir": "build"
}
}
]
}
],
"routes": [
{
"src": "/api/(.*)",
"dest": "/server/$1"
},
{
"src": "/(.*)",
"dest": "/client/$1"
}
],
"rewrites": [
{ "source": "/robots.txt", "destination": "/public/robots.txt" },
{ "source": "/sitemap.xml", "destination": "/public/sitemap.xml" },
{ "source": "/api/(.*)", "destination": "/server/api/$1" },
{ "source": "/(.*)", "destination": "/client/$1" }
]
}

0 comments on commit 9ac237b

Please sign in to comment.