-
Notifications
You must be signed in to change notification settings - Fork 0
193 lines (173 loc) · 7.18 KB
/
Copy pathdeploy-dev.yml
File metadata and controls
193 lines (173 loc) · 7.18 KB
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
name: deploy-dev
on:
push:
branches:
- develop
jobs:
changes:
name: Check changed projects
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
web: ${{ steps.filter.outputs.web }}
projects: ${{ steps.filter.outputs.changes }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.LEMON_BOT_TOKEN }}
- uses: dorny/paths-filter@v3
id: filter
with:
base: 'develop'
filters: |
web:
- 'apps/web/**'
- 'assets/**'
- 'libs/**'
version-update:
needs: changes
if: ${{ fromJson(needs.changes.outputs.projects)[0] != null }}
name: Update Versions
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
outputs:
root-version: ${{ steps.version-update.outputs.root-version }}
web-version: ${{ steps.version-update.outputs.web-version }}
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.LEMON_BOT_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Get Yarn cache path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Update versions and changelog
id: version-update
run: |
chmod +x scripts/version-update.js
node scripts/version-update.js
# Export updated versions
# root
if [ -f "package.json" ]; then
ROOT_VERSION=$(node -p "require('./package.json').version")
echo "root-version=${ROOT_VERSION}" >> $GITHUB_OUTPUT
fi
# web
if [ -f "apps/web/package.json" ]; then
WEB_VERSION=$(node -p "require('./apps/web/package.json').version")
echo "web-version=${WEB_VERSION}" >> $GITHUB_OUTPUT
fi
- name: Commit and push changes
env:
ROOT_VERSION: ${{ steps.version-update.outputs.root-version }}
run: |
git add .
git commit -m "chore(release): bump root version to ${ROOT_VERSION} [skip ci]" || echo "No changes to commit"
git push
create-draft-release:
needs: [changes, version-update]
if: ${{ fromJson(needs.changes.outputs.projects)[0] != null }}
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: release-drafter/release-drafter@v5
id: draft
with:
publish: false
version: ${{ needs.version-update.outputs.root-version }}
tag: ${{ needs.version-update.outputs.root-version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build-and-deploy:
needs: [changes, version-update]
runs-on: ubuntu-latest
environment: dev
name: Build and Deploy
strategy:
fail-fast: false
matrix:
project: [web]
include:
- project: web
version: ${{ needs.version-update.outputs.web-version }}
should_run: ${{ needs.changes.outputs.web == 'true' }}
steps:
- name: Skip if no changes
if: ${{ matrix.should_run }}
run: echo "Processing ${{ matrix.project }}"
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.LEMON_BOT_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
- name: Get Yarn cache path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: Cache dependencies
uses: actions/cache@v3
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
node_modules
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
if: steps.cache-dependencies.outputs.cache-hit != 'true'
run: yarn install --frozen-lockfile
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
- name: Deploy to DEV
env:
BUCKET_NAME: ${{ secrets.BUCKET_NAME }}
DEV_DISTRIBUTION_ID: ${{ secrets.DEV_DISTRIBUTION_ID }}
PROD_DISTRIBUTION_ID: ${{ secrets.PROD_DISTRIBUTION_ID }}
VITE_ENV: ${{ vars.VITE_ENV }}
VITE_PROJECT: ${{ vars.VITE_PROJECT }}
VITE_OAUTH_ENDPOINT: ${{ vars.VITE_OAUTH_ENDPOINT }}
VITE_BACKEND_ENDPOINT: ${{ vars.VITE_BACKEND_ENDPOINT }}
VITE_TRANSLATE_ENDPOINT: ${{ vars.VITE_TRANSLATE_ENDPOINT }}
VITE_HOST: ${{ vars.VITE_HOST }}
VITE_SOCIAL_OAUTH_ENDPOINT: ${{ vars.VITE_SOCIAL_OAUTH_ENDPOINT }}
VITE_CONTENT_ENDPOINT: ${{ vars.VITE_CONTENT_ENDPOINT }}
VITE_IMAGE_API_ENDPOINT: ${{ vars.VITE_IMAGE_API_ENDPOINT }}
VITE_CODES_HOST: ${{ vars.VITE_CODES_HOST }}
VITE_CHATBOTS_API_ENDPOINT: ${{ vars.VITE_CHATBOTS_API_ENDPOINT }}
run: |
chmod +x scripts/deploy-${{ matrix.project }}.sh
yarn ${{ matrix.project }}:deploy:dev