This repository has been archived by the owner on Aug 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (88 loc) · 3.03 KB
/
nodejs-ci.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
# Node.js v14 と v16 でビルド・テストを実行する
name: Node CI
on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master
jobs:
ci:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node: [16]
steps:
- name: 🛎 Checkout
uses: actions/checkout@v3
- name: 🏗 Setup node env
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- name: 📃 Check package.json definition
id: package-json
run: |
compile=$(cat package.json | jq '.scripts | has("compile")')
build=$(cat package.json | jq '.scripts | has("build")')
generate=$(cat package.json | jq '.scripts | has("generate")')
package=$(cat package.json | jq '.scripts | has("package")')
lint=$(cat package.json | jq '.scripts | has("lint")')
test=$(cat package.json | jq '.scripts | has("test")')
echo "compile: $compile"
echo "build: $build"
echo "generate: $generate"
echo "package: $package"
echo "lint: $lint"
echo "test: $test"
echo "compile=$compile" >> $GITHUB_OUTPUT
echo "build=$build" >> $GITHUB_OUTPUT
echo "generate=$generate" >> $GITHUB_OUTPUT
echo "package=$package" >> $GITHUB_OUTPUT
echo "lint=$lint" >> $GITHUB_OUTPUT
echo "test=$test" >> $GITHUB_OUTPUT
- name: 🛠 Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- name: 📦 Cache node_modules
uses: actions/cache@v3
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: 👨🏻💻 Install dependencies
run: yarn
- name: 👀 Run linter
if: steps.package-json.outputs.lint == 'true'
run: yarn lint
- name: 🎁 Run package
if: steps.package-json.outputs.package == 'true'
run: yarn package
- name: 🏃 Run compile
if: steps.package-json.outputs.compile == 'true'
run: yarn compile
- name: 🏗️ Run build & generate (Nuxt.js)
if: steps.package-json.outputs.build == 'true' && steps.package-json.outputs.generate == 'true'
run: |
yarn build
yarn generate
- name: 🧪 Run tests
if: steps.package-json.outputs.test == 'true'
run: yarn test
- name: ☑️ Check Dependencies
run: npx depcheck
- name: Check exists dist directory
id: check-dist
run: |
echo "exists=$(test -d dist && echo true || echo false)" >> $GITHUB_OUTPUT
- name: 📦 Upload artifact
if: steps.check-dist.outputs.exists == 'true'
uses: actions/upload-artifact@v3
with:
name: dist
path: dist