-
Notifications
You must be signed in to change notification settings - Fork 0
235 lines (192 loc) · 6.42 KB
/
github.action.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
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
lint_and_test_ui_fundamentals:
name: "Lint and Test UI Fundamentals"
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 16.13.x
cache: npm
# - name: Change directory to ui-fundamentals
# run: cd ui-fundamentals && ls -a
- name: Install dependencies
working-directory: ui-fundamentals
run: npm install
- name: Lint code
working-directory: ui-fundamentals
run: npm run lint
- name: Test code
working-directory: ui-fundamentals
run: npm test
- name: Link check (warnings, changed files)
run: |
./script/rendered-content-link-checker.mjs \
--language en \
--max 100 \
--check-anchors \
--check-images \
--verbose \
--list $HOME/files.json
# for future updates
# lint_and_test_the_wild_oasis:
# name: "Lint and Test The Wild Oasis"
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v2
# - name: Change directory to the-wild-oasis
# run: cd react-practices/the-wild-oasis
# - name: Install dependencies
# run: npm install
# - name: Lint code
# run: npm run lint
# - name: Test code
# run: npm test
# lint_and_test_movies:
# name: "Lint and Test Movies"
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v2
# - name: Change directory to movies
# run: cd react-practices/movies
# - name: Install dependencies
# run: npm install
# - name: Lint code
# run: npm run lint
# - name: Test code
# run: npm test
build_and_deploy:
name: "Build and Deploy to Netlify"
runs-on: ubuntu-latest
needs: [
lint_and_test_ui_fundamentals,
# lint_and_test_the_wild_oasis,
# lint_and_test_movies,
]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 16.13.x
# cache: npm
# - name: Change directory to react-practices
# run: cd react-practices
- name: Check for merge conflicts in all projects
run: |
for dir in ui-fundamentals the-wild-oasis movies; do
cd $dir
if git diff --quiet; then
echo "No merge conflicts found in $dir"
else
echo "Merge conflicts found in $dir. Please resolve conflicts and try again."
git status
exit 1
fi
cd ..
done
- name: Gather files changed
id: gather_files_changed
uses: trilom/file-changes-action@a6ca26c14274c33b15e6499323aac178af06ad4b
with:
fileOutput: "json"
- name: Deploy if conditions met
run: |
for dir in ui-fundamentals the-wild-oasis movies; do
cd $dir
# Check if there are changed files
if [ -s $HOME/files.json ]; then
echo "Files changed in $dir. Proceeding with deployment..."
# Print all the files changed
echo "Files changed:"
cat $HOME/files.json
npm install
npm run build
# Adjust the NETLIFY_SITE_ID according to the directory/project
case $dir in
"ui-fundamentals")
NETLIFY_SITE_ID="${{ secrets.NETLIFY_SITE_ID_UI_FUNDAMENTALS }}"
;;
"the-wild-oasis")
NETLIFY_SITE_ID="${{ secrets.NETLIFY_SITE_ID_THE_WILD_OASIS }}"
;;
"movies")
NETLIFY_SITE_ID="${{ secrets.NETLIFY_SITE_ID_MOVIES }}"
;;
*)
echo "Unknown project directory: $dir"
exit 1
;;
esac
netlify deploy --prod --message "Deploy from GitHub Actions" --dir=dist --site=$NETLIFY_SITE_ID
else
echo "No files changed in $dir. Skipping deployment."
fi
cd ..
done
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
HOME: ${{ github.workspace }}
# deploy:
# name: "Deploy to Netlify"
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v2
# with:
# submodules: recursive
# - name: Install dependencies and build project
# run: |
# cd ui-fundamentals
# npm install
# npm run build
# - name: Netlify Deploy
# uses: jsmrcaga/action-netlify-deploy@v2.1.0
# with:
# # build_directory: ./ui-fundamentals/dist
# NETLIFY_DEPLOY_TO_PROD: true
# deploy-message: "Deploy from GitHub Actions"
# env:
# NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
# NETLIFY_DEPLOY_TO_PROD: true
# NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
# deploy_to_vercel:
# runs-on: ubuntu-latest
# needs: build
# env:
# VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
# VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
# steps:
# # Checkout code including submodules
# - name: Checkout code
# uses: actions/checkout@v2
# with:
# submodules: recursive
# # Change directory to ui-fundamentals
# - name: Change directory to ui-fundamentals
# run: cd ui-fundamentals
# # Install Vercel CLI
# - name: Install Vercel CLI
# run: npm install --global vercel@latest
# # Pull Vercel Environment Information
# - name: Pull Vercel Environment Information
# run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
# # Build Project Artifacts
# - name: Build Project Artifacts
# run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
# # Deploy Project Artifacts to Vercel
# - name: Deploy Project Artifacts to Vercel
# run: |
# vercel deploy --prod --scope=./ui-fundamentals --token=${{ secrets.VERCEL_TOKEN }}