-
Notifications
You must be signed in to change notification settings - Fork 0
136 lines (131 loc) · 3.98 KB
/
build.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
name: Build
on: [push]
jobs:
#
# dependencies job
#
dependencies:
name: Dependencies
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js and NPM
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
cache: npm
always-auth: true
registry-url: https://registry.npmjs.org
- name: Install dependencies with NPM
run: npm ci
env:
NODE_AUTH_TOKEN: ${{ secrets.BUILD_USER_TOKEN || github.token }}
- name: Archive node_modules
run: tar --use-compress-program "zstd -T0 --long=31 -1" -cf node_modules.tar.zstd -P node_modules
- name: Persisting node_modules artifact
uses: actions/upload-artifact@v3
with:
name: node_modules.tar.zstd
path: node_modules.tar.zstd
retention-days: 2
#
# lint job
#
lint:
runs-on: ubuntu-latest
needs: [dependencies]
steps:
# Setup
- uses: actions/checkout@v3
with:
token: ${{ secrets.BUILD_USER_TOKEN || github.token }} # allows commit of any fixes to trigger a new workflow run
- uses: actions/checkout@v3
- name: Setup Node.js and NPM
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
- name: Restore node_modules artifact
uses: actions/download-artifact@v3
with:
name: node_modules.tar.zstd
- name: Unarchive node_modules
run: tar --use-compress-program "zstd -d --long=31" -xf node_modules.tar.zstd
# Commit Signing
- name: Import build user's GPG key
env:
GPG_KEY: ${{ secrets.BUILD_USER_GPG_KEY }}
GPG_KEY_PASSPHRASE: ${{ secrets.BUILD_USER_GPG_KEY_PASSPHRASE }}
if: env.GPG_KEY != null && env.GPG_KEY_PASSPHRASE != null
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ env.GPG_KEY }}
passphrase: ${{ env.GPG_KEY_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
# Lint
- name: Run linters
uses: wearerequired/lint-action@v2
with:
prettier: true
eslint: true
eslint_args: "--ext '.ts,.js' --ignore-path '.gitignore' --ignore-pattern '.github/*'"
continue_on_error: false
auto_fix: ${{ secrets.BUILD_USER_TOKEN && 'true' || 'false' }}
git_name: equabot
git_email: git@equalogic.com
#
# build job
#
build:
runs-on: ubuntu-latest
needs: [dependencies]
steps:
# Setup
- uses: actions/checkout@v3
- name: Setup Node.js and NPM
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
- name: Restore node_modules artifact
uses: actions/download-artifact@v3
with:
name: node_modules.tar.zstd
- name: Unarchive node_modules
run: tar --use-compress-program "zstd -d --long=31" -xf node_modules.tar.zstd
# Build
- name: Build application
run: npm run build
env:
CI: true
- name: Check build worked correctly
run: |
if [ ! -f ./dist/index.js ]; then
echo "Something went wrong: no ./dist/index.js file was built!"
exit 1
else
echo "Build appears to be successful: ./dist/index.js was created"
fi
#
# test job
#
test:
runs-on: ubuntu-latest
needs: [dependencies]
steps:
# Setup
- uses: actions/checkout@v3
- name: Setup Node.js and NPM
uses: actions/setup-node@v3
with:
node-version-file: .nvmrc
- name: Restore node_modules artifact
uses: actions/download-artifact@v3
with:
name: node_modules.tar.zstd
- name: Unarchive node_modules
run: tar --use-compress-program "zstd -d --long=31" -xf node_modules.tar.zstd
# Tests
- name: Run project tests
run: npm run test
env:
CI: true