-
Notifications
You must be signed in to change notification settings - Fork 15
73 lines (62 loc) · 2.52 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: Vercel Deployment | Mock app
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
on:
push:
branches:
- develop
paths-ignore:
- '**/*.md'
- '**/*.json'
- '**/*.yml'
jobs:
deploy-app:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Node.js version
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Create .env file for server
run: |
echo "APP_PORT=${{ secrets.APP_PORT }}" >> ./server/.env
echo "OAUTH_CLIENT_SECRET=${{ secrets.OAUTH_CLIENT_SECRET }}" >> ./server/.env
echo "OAUTH_CLIENT_ID=${{ secrets.OAUTH_CLIENT_ID }}" >> ./server/.env
echo "OAUTH_REDIRECT_URL=${{ secrets.OAUTH_REDIRECT_URL }}" >> ./server/.env
echo "ENCRYPTION_KEY=${{ secrets.ENCRYPTION_KEY }}" >> ./server/.env
echo "NODE_ENV=${{ secrets.NODE_ENV }}" >> ./server/.env
- name: Create .env file for client
run: |
echo "VITE_APP_TITLE=${{ secrets.VITE_APP_TITLE }}" >> ./client/.env
echo "VITE_APP_SLOGAN=${{ secrets.VITE_APP_SLOGAN }}" >> ./client/.env
echo "VITE_BACKEND_ENDPOINT=${{ secrets.VITE_BACKEND_ENDPOINT }}" >> ./client/.env
echo "VITE_ENVIRONMENT=${{ secrets.VITE_ENVIRONMENT }}" >> ./client/.env
echo "VITE_MOCK_CALENDER=${{ secrets.VITE_MOCK_CALENDER }}" >> ./client/.env
- name: Install dependencies using npm workspaces
run: npm install
- name: Build all dependencies
run: npm run build
- name: Install Vercel CLI
run: npm install --global vercel@latest
- name: Read .env file and set environment variables
run: |
# Check if the server/.env file exists
if [ -f server/.env ]; then
# Loop through each line in the .env file
while IFS='=' read -r key value; do
# Skip empty lines or lines starting with a comment
if [ ! -z "$key" ] && [[ ! "$key" =~ ^# ]]; then
# Add environment variable to Vercel for production environment
echo "$value" | vercel env add "$key" production --token=${{ secrets.VERCEL_TOKEN }} --force
fi
done < server/.env
else
echo "server/.env not found!"
exit 1
fi
- name: Deploy to Vercel
run: vercel deploy --prod --token=${{ secrets.VERCEL_TOKEN }}