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 f5040a5
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 5 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Build and Deploy

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

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

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "21.2.0"

- name: Install dependencies
run: |
echo -e "\e[34mInstalling dependencies...\e[0m"
cd server
npm install
- name: Build project
run: |
echo -e "\e[34mBuilding project...\e[0m"
cd server
npm run build
ls
if [ ! -d "dist" ]; then
echo -e "\e[31mBuild failed: 'dist' directory not found.\e[0m"
exit 1
else
echo -e "\e[32mBuild succeeded.\e[0m"
fi
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: dist
path: server/dist/

- name: Deploy server to Vercel
run: |
echo -e "\e[34mDeploying server to Vercel...\e[0m"
npm install -g vercel
npx vercel --prod --token ${{ secrets.VERCEL_TOKEN }} --cwd server --yes
- name: Deploy client to Vercel
run: |
echo -e "\e[34mDeploying client to Vercel...\e[0m"
npm install -g vercel
npx vercel --prod --token ${{ secrets.VERCEL_TOKEN }} --cwd client --yes
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
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
5 changes: 2 additions & 3 deletions server/vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
"version": 2,
"builds": [
{
"src": "package.json",
"use": "@vercel/node",
"config": { "distDir": "dist" }
"src": "dist/index.js",
"use": "@vercel/node"
}
],
"routes": [
Expand Down

0 comments on commit f5040a5

Please sign in to comment.