Update .gitlab/.gitlab-ci.yml file

This commit is contained in:
Zakary Timson 2023-03-20 20:32:28 +00:00
parent 0c93aa34e2
commit d21bd3e79c

View File

@ -2,25 +2,24 @@ image: node:16
npm:
stage: build
artifacts:
paths:
- dist
expire_in: 1 week
cache:
- key:
files:
- package.json
- package-lock.json
paths:
- node_modules
- package-lock.json
policy: pull-push
- key: $CI_PIPELINE_ID
paths:
- dist
policy: push
script:
- npm i
- npm install
- npm run build
artifacts:
paths:
- dist
expire_in: 1 week
rules:
- if: $CI_COMMIT_BRANCH
@ -29,22 +28,19 @@ audit:
cache:
- key:
files:
- package.json
- package-lock.json
paths:
- node_modules
policy: pull
script:
- AUDIT=$(npm audit)
- echo "vulnerabilities_high $(echo $AUDIT | grep -oE '[0-9]+ high' | grep -oE '[0-9]+' || echo 0)" > metrics.txt
- echo "vulnerabilities_medium $(echo $AUDIT | grep -oE '[0-9]+ moderate' | grep -oE '[0-9]+' || echo 0)" >> metrics.txt
- echo "vulnerabilities_low $(echo $AUDIT | grep -oE '[0-9]+ low' | grep -oE '[0-9]+' || echo 0)" >> metrics.txt
- echo "$AUDIT"
- echo "vulnerabilities_high $(npm audit | grep -oE '[0-9]+ high' | grep -oE '[0-9]+' || echo 0)" > metrics.txt
- echo "vulnerabilities_medium $(npm audit | grep -oE '[0-9]+ moderate' | grep -oE '[0-9]+' || echo 0)" >> metrics.txt
- echo "vulnerabilities_low $(npm audit | grep -oE '[0-9]+ low' | grep -oE '[0-9]+' || echo 0)" >> metrics.txt
artifacts:
reports:
metrics: metrics.txt
rules:
- if: $CI_COMMIT_BRANCH
allow_failure: true
registry:
stage: deploy
@ -71,11 +67,10 @@ tag:
entrypoint: [""]
cache: []
before_script:
- git remote set-url origin "https://Tagger:$DEPLOY_TOKEN@$CI_SERVER_HOST/$CI_PROJECT_PATH.git"
- git remote set-url origin "https://ReleaseBot:$DEPLOY_TOKEN@$CI_SERVER_HOST/$CI_PROJECT_PATH.git"
script:
- VERSION=$(cat package.json | grep version | grep -Eo ':.+' | grep -Eo '[[:alnum:]\.\/\-]+')
- git tag -f $VERSION $CI_COMMIT_SHA
- git push -f origin $VERSION
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
allow_failure: true