Update .gitlab/.gitlab-ci.yml file

This commit is contained in:
Zakary Timson 2023-03-20 20:15:24 +00:00
parent 99f09c6ac6
commit c98e0d8d29

View File

@ -7,14 +7,10 @@ stages:
npm: npm:
stage: build stage: build
artifacts:
paths:
- dist
expire_in: 1 week
cache: cache:
- key: - key:
files: files:
- package.json - package-lock.json
paths: paths:
- node_modules - node_modules
policy: pull-push policy: pull-push
@ -23,26 +19,33 @@ npm:
- dist - dist
policy: push policy: push
script: script:
- npm i - npm install
- npm run build - npm run build
artifacts:
paths:
- dist
expire_in: 1 week
rules: rules:
- if: $CI_COMMIT_BRANCH - if: $CI_COMMIT_BRANCH
audit: audit:
stage: test stage: test
cache: [ ] cache:
- key:
files:
- package-lock.json
paths:
- node_modules
policy: pull
script: script:
- AUDIT=$(npm audit) - echo "vulnerabilities_high $(npm audit | grep -oE '[0-9]+ high' | grep -oE '[0-9]+' || echo 0)" > metrics.txt
- echo "vulnerabilities_high $(echo $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_medium $(echo $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
- echo "vulnerabilities_low $(echo $AUDIT | grep -oE '[0-9]+ low' | grep -oE '[0-9]+' || echo 0)" >> metrics.txt
- echo "$AUDIT"
artifacts: artifacts:
reports: reports:
metrics: metrics.txt metrics: metrics.txt
rules: rules:
- if: $CI_COMMIT_BRANCH - if: $CI_COMMIT_BRANCH
allow_failure: true
registry: registry:
stage: deploy stage: deploy