-
Notifications
You must be signed in to change notification settings - Fork 10
89 lines (84 loc) · 2.34 KB
/
node.js.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
name: Demo CI
on:
push:
branches: ['main']
paths-ignore:
- 'README.md'
- 'LICENSE'
- '.gitignore'
- 'exercises/**'
pull_request:
branches: ['main']
paths-ignore:
- 'README.md'
- 'LICENSE'
- '.gitignore'
- 'exercises/**'
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
modules_preprocess:
name: Install dependencies
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- uses: actions/checkout@v3
- name: Use Node.js 18
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
- uses: actions/cache@v3
id: npm-cache
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/package-lock.json') }}
- name: Install npm dependencies
if: steps.npm-cache.outputs.cache-hit != 'true'
run: npm ci --prefer-offline --no-audit
- name: Compress dependencies
run: tar -cvf dependencies.tar node_modules
- name: Upload node_modules artifact for later use
uses: actions/upload-artifact@v3
with:
name: modules
path: dependencies.tar
retention-days: 1
quality_assurance:
name: Apply lint and test processes to the source code
runs-on: ubuntu-latest
needs: modules_preprocess
timeout-minutes: 3
strategy:
matrix:
task: [lint, test]
steps:
- uses: actions/checkout@v3
- name: Use Node.js 18
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Download node_modules artifact
uses: actions/download-artifact@v3
with:
name: modules
- name: Extract dependencies
run: tar -xf dependencies.tar
- name: Run ${{ matrix.task}}
run: npm run ${{ matrix.task }}
docker_build:
name: Build the production docker image
runs-on: ubuntu-latest
needs: modules_preprocess
timeout-minutes: 3
steps:
- uses: actions/checkout@v3
- name: Download node_modules artifact
uses: actions/download-artifact@v3
with:
name: modules
- name: Extract dependencies
run: tar -xf dependencies.tar
- run: docker build . -t greenict/demo-api