-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
120 lines (113 loc) · 3.26 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
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
stages:
- debug
- lint
- test
- build
- deploy
- review
- dast
- staging
- canary
- production
- incremental rollout 10%
- incremental rollout 25%
- incremental rollout 50%
- incremental rollout 100%
- performance
- cleanup
- update
update:
image: node:18-alpine
stage: update
before_script:
- apk add git wget dotnet6-targeting-pack dotnet6-sdk
- git config --global user.name metahkg-bot
- git config --global user.email bot@metahkg.org
- git checkout $CI_COMMIT_BRANCH
- git remote set-url origin "https://root:${gitlab_token}@$CI_SERVER_HOST/$CI_PROJECT_PATH"
script:
- yarn install
- yarn generate
- git add -A
- git commit -a -m "update from latest openapi" || echo "nothing to commit, skipping"
- git push origin $CI_COMMIT_BRANCH
artifacts:
paths:
- dist
rules:
- if: $UPDATE
tagging:
image: alpine:latest
stage: deploy
allow_failure: true
before_script:
- apk add git nodejs-current
script:
- git config --global user.name metahkg-bot
- git config --global user.email bot@metahkg.org
- tag=$(node -e "console.log(require('./package.json').version)")
- if [ $CI_COMMIT_BRANCH = "dev" ]; then tag=${tag}-dev; fi;
- git tag "$tag"
- git push https://root:$gitlab_token@$CI_SERVER_HOST/$CI_PROJECT_PATH.git $tag
rules:
- if: $UPDATE
when: never
- if: "$CI_COMMIT_TAG"
when: never
- if: $CI_COMMIT_BRANCH == "dev" || $CI_COMMIT_BRANCH == "master"
changes:
- package.json
publish:
image: node:latest
stage: deploy
allow_failure: true
script:
- yarn install
- yarn lint
- yarn build
- echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' >> .npmrc
- NPM_PACKAGE_ORIGINAL_VERSION=$(node -p "require('./package.json').version")
- NPM_PACKAGE_VERSION=$CI_COMMIT_TAG
- sed -i "s/${NPM_PACKAGE_ORIGINAL_VERSION}/${NPM_PACKAGE_VERSION}/" package.json
- if [ "$CI_COMMIT_TAG" = "${NPM_PACKAGE_ORIGINAL_VERSION}-dev" ]; then npm publish --tag dev --access=public; else npm publish --access=public; fi;
- echo "@${CI_PROJECT_NAMESPACE}:registry=https://${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/" > .npmrc
- echo "//${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=\"${CI_JOB_TOKEN}\"" >> .npmrc
- if [ "$CI_COMMIT_TAG" = "${NPM_PACKAGE_ORIGINAL_VERSION}-dev" ]; then npm publish --tag dev --access=public; else npm publish --access=public; fi;
rules:
- if: $UPDATE
when: never
- if: "$CI_COMMIT_TAG"
build:
stage: build
retry: 2
rules:
- if: $UPDATE
when: never
- if: "$CI_COMMIT_BRANCH"
container_scanning:
stage: review
needs: ["build"]
variables:
GIT_STRATEGY: fetch
CI_APPLICATION_REPOSITORY: "$CI_REGISTRY_IMAGE/$CI_COMMIT_BRANCH"
CI_APPLICATION_TAG: $CI_COMMIT_SHA
CLAIR_OUTPUT: High
artifacts:
paths:
- gl-container-scanning-report.json
rules:
- if: $UPDATE
when: never
- if: "$CI_COMMIT_TAG"
when: never
- if: $CI_COMMIT_BRANCH == "master" || $CI_COMMIT_BRANCH == "dev"
exists:
- Dockerfile
code_quality:
stage: test
rules:
- if: $UPDATE
when: never
- if: "$CI_COMMIT_BRANCH"
include:
- template: Auto-DevOps.gitlab-ci.yml