-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (140 loc) · 4.47 KB
/
deploy-vercel.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: Deploy to Production Environment
# This workflow deploys the backend, a full-server express app to Vercel
# as opposed to their recommended approach of deploying serverless functions
# using NextJS "pages/api". Vercel CLI v28.2.0 is used for deployment
# This workflow will trigger on any tag/release created on *any* branch
# Make sure to create tags/releases only from the "master" branch for consistency
on:
release:
types: [published]
jobs:
lint-client:
name: Lint and Export client
if: github.event.release.target_commitish == 'master'
runs-on: ubuntu-latest
env:
NEXT_PUBLIC_BASE_PATH: ${{ secrets.NEXT_PUBLIC_BASE_PATH }}
BASE_API_URL: ${{ secrets.BASE_API_URL }}
steps:
- name: Checkout the repository
uses: actions/checkout@v3
- name: Use NodeJS v16.14.2
uses: actions/setup-node@v3
with:
node-version: 16.14.2
- name: Install Dependencies and lint
run: |
cd client
npm install
- name: Lint
run: |
cd client
npm run lint
- name: Export static files
run: |
cd client
npm run export
mv out/404/index.html out/404.html
- name: Disable Jekyll
run: |
cd client
touch out/.nojekyll
- name: Archive Development Artifact
uses: actions/upload-artifact@v3
with:
name: main-out
path: client/out
retention-days: 3
lint-server:
name: Lint Server
if: github.event.release.target_commitish == 'master'
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v3
- name: Use NodeJS v16.14.2
uses: actions/setup-node@v3
with:
node-version: 16.14.2
- name: Install Dependencies and lint
run: |
cd server
npm install
npm run lint
deploy-client:
name: Deploy client to Github Pages
if: github.event.release.target_commitish == 'master'
needs: lint-client
runs-on: ubuntu-latest
steps:
- name: Download Artifact
uses: actions/download-artifact@v3
with:
name: main-out
- name: List files for publish
run: ls -l -a
- name: Deploy to Github Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./
publish_branch: gh-pages
deploy-server:
name: Deploy Server to Vercel
if: github.event.release.target_commitish == 'master'
needs: lint-server
runs-on: ubuntu-latest
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
steps:
- name: Checkout the repository
uses: actions/checkout@v3
- name: Use NodeJS v16.14.2
uses: actions/setup-node@v3
with:
node-version: 16.14.2
- name: Install Vercel CLI
run: npm install --global [email protected]
- name: Pull Vercel Environment Information
run: |
cd server
vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts
run: |
cd server
vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Project Artifacts to Vercel
run: |
cd server
vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
- name: Post Deployment Clean-up
run: |
cd server
rm -r -f .vercel
docker-build-push:
name: Push Image to Docker Hub
if: github.event.release.target_commitish == 'master' && vars.DOCKERHUB_USERNAME != ''
needs:
- lint-client
- lint-server
runs-on: ubuntu-latest
steps:
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Checkout the repository
uses: actions/checkout@v3
with:
ref: ${{ github.event.release.tag_name }}
- name: Create env variables
run: |
cp client/.env.example client/.env
cp server/.env.example server/.env
- name: Build Image
run: docker compose -f docker-compose.dev.yml build
- name: Push Image to Docker Hub
run: docker compose -f docker-compose.dev.yml push