-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
60 lines (52 loc) · 1.35 KB
/
.gitlab-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
variables:
YARN_CONFIG_CACHE: .yarn-cache/
workflow:
rules:
- if: '$CI_COMMIT_REF_NAME == "master"'
# todo 使用include 分离各个任务到不同的文件中去
stages:
- test
- build
- image
- deploy
.yarn-cache:
# Job 以*点*( . )*开头*的键不会被处理
cache:
- key:
files:
# 根据文件计算出 cache:key,不再使用的key的缓存会有定期清理机制吗
# 使用同一个 runner 运行不同 job,job 之间可以共享缓存,如果已经存在 key 缓存,不再重复处理,直接使用上一步产生的缓存
- yarn.lock
paths:
- ${YARN_CONFIG_CACHE}
run-test:
image: node:16.16.0
stage: test
extends: .yarn-cache
interruptible: true # 短时间重复触发,自动取消旧的流水线
script:
- yarn install --cache-folder ${YARN_CONFIG_CACHE}
- yarn test:unit
build-dist:
only:
- master
image: node:16.16.0
stage: build
extends: .yarn-cache
interruptible: true
script:
- yarn install --cache-folder ${YARN_CONFIG_CACHE}
- yarn build
artifacts:
name: "dist"
paths:
- dist/
expire_in: 1 day
build-image:
stage: image
image: docker:latest
needs: ["build-dist"]
interruptible: true
script:
- docker build -t vue3-template-frontend .
- docker run -d -p 8088:80 vue3-template-frontend