Update .gitlab/.gitlab-ci.yml file
This commit is contained in:
parent
2b1e7d6816
commit
c3d6c79fe3
@ -2,25 +2,24 @@ image: node:16
|
|||||||
|
|
||||||
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
|
||||||
- package-lock.json
|
|
||||||
policy: pull-push
|
policy: pull-push
|
||||||
- key: $CI_PIPELINE_ID
|
- key: $CI_PIPELINE_ID
|
||||||
paths:
|
paths:
|
||||||
- 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
|
||||||
|
|
||||||
@ -29,16 +28,14 @@ audit:
|
|||||||
cache:
|
cache:
|
||||||
- key:
|
- key:
|
||||||
files:
|
files:
|
||||||
- package.json
|
- package-lock.json
|
||||||
paths:
|
paths:
|
||||||
- node_modules
|
- node_modules
|
||||||
policy: pull
|
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
|
||||||
@ -64,8 +61,8 @@ jest:
|
|||||||
rules:
|
rules:
|
||||||
- if: $CI_COMMIT_BRANCH
|
- if: $CI_COMMIT_BRANCH
|
||||||
|
|
||||||
registry-gitlab:
|
registry:
|
||||||
stage: deploy
|
stage: publish
|
||||||
cache:
|
cache:
|
||||||
- key:
|
- key:
|
||||||
files:
|
files:
|
||||||
@ -81,49 +78,28 @@ registry-gitlab:
|
|||||||
- VERSION=$(cat package.json | grep version | grep -Eo ':.+' | grep -Eo '[[:alnum:]\.\/\-]+')
|
- VERSION=$(cat package.json | grep version | grep -Eo ':.+' | grep -Eo '[[:alnum:]\.\/\-]+')
|
||||||
- if [ "$CI_COMMIT_BRANCH" != "$CI_DEFAULT_BRANCH" ] && [ "$VERSION" != *"-$CI_COMMIT_BRANCH" ]; then VERSION="$VERSION-$(echo "$CI_COMMIT_BRANCH" | sed -E "s/[_/]/-/g")"; npm version --no-git-tag-version $VERSION; fi
|
- if [ "$CI_COMMIT_BRANCH" != "$CI_DEFAULT_BRANCH" ] && [ "$VERSION" != *"-$CI_COMMIT_BRANCH" ]; then VERSION="$VERSION-$(echo "$CI_COMMIT_BRANCH" | sed -E "s/[_/]/-/g")"; npm version --no-git-tag-version $VERSION; fi
|
||||||
script:
|
script:
|
||||||
- PACKAGES=$(curl -s -H "PRIVATE-TOKEN:$DEPLOY_TOKEN" "https://$CI_SERVER_HOST/api/v4/projects/$CI_PROJECT_ID/packages")
|
- PACKAGES=$(curl -s -H "PRIVATE-TOKEN:$DEPLOY_TOKEN" https://$CI_SERVER_HOST/api/v4/projects/$CI_PROJECT_ID/packages)
|
||||||
- ID=$(node -pe "JSON.parse(process.argv[1]).find(p => p['version'] == process.argv[2])?.id || ''" $PACKAGES $VERSION)
|
- ID=$(node -pe "JSON.parse(process.argv[1]).find(p => p['version'] == process.argv[2])?.id || ''" $PACKAGES $VERSION)
|
||||||
- if [ -n "$ID" ]; then curl -s -X DELETE -H "PRIVATE-TOKEN:$DEPLOY_TOKEN" https://$CI_SERVER_HOST/api/v4/projects/$CI_PROJECT_ID/packages/$ID; fi
|
- if [ -n "$ID" ]; then curl -s -X DELETE -H "PRIVATE-TOKEN:$DEPLOY_TOKEN" https://$CI_SERVER_HOST/api/v4/projects/$CI_PROJECT_ID/packages/$ID; fi
|
||||||
- printf "@cwb:registry=https://$CI_SERVER_HOST/api/v4/projects/$CI_PROJECT_ID/packages/npm/\n//$CI_SERVER_HOST/api/v4/projects/$CI_PROJECT_ID/packages/npm/:_authToken=$DEPLOY_TOKEN" > .npmrc
|
- printf "@transmute:registry=https://$CI_SERVER_HOST/api/v4/projects/$CI_PROJECT_ID/packages/npm/\n//$CI_SERVER_HOST/api/v4/projects/$CI_PROJECT_ID/packages/npm/:_authToken=$DEPLOY_TOKEN" > .npmrc
|
||||||
- npm publish
|
- npm publish
|
||||||
rules:
|
rules:
|
||||||
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
||||||
allow_failure: true
|
|
||||||
- if: $CI_COMMIT_BRANCH
|
- if: $CI_COMMIT_BRANCH
|
||||||
when: manual
|
when: manual
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
|
||||||
registry-npm:
|
|
||||||
stage: deploy
|
|
||||||
cache:
|
|
||||||
- key:
|
|
||||||
files:
|
|
||||||
- package.json
|
|
||||||
paths:
|
|
||||||
- node_modules
|
|
||||||
policy: pull
|
|
||||||
- key: $CI_PIPELINE_ID
|
|
||||||
paths:
|
|
||||||
- dist
|
|
||||||
policy: pull
|
|
||||||
script:
|
|
||||||
- npm publish
|
|
||||||
rules:
|
|
||||||
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
tag:
|
tag:
|
||||||
stage: deploy
|
stage: publish
|
||||||
image:
|
image:
|
||||||
name: alpine/git
|
name: alpine/git
|
||||||
entrypoint: [""]
|
entrypoint: [""]
|
||||||
cache: []
|
cache: []
|
||||||
before_script:
|
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:
|
script:
|
||||||
- VERSION=$(cat package.json | grep version | grep -Eo ':.+' | grep -Eo '[[:alnum:]\.\/\-]+')
|
- VERSION=$(cat package.json | grep version | grep -Eo ':.+' | grep -Eo '[[:alnum:]\.\/\-]+')
|
||||||
- git tag -f $VERSION $CI_COMMIT_SHA
|
- git tag -f $VERSION $CI_COMMIT_SHA
|
||||||
- git push -f origin $VERSION
|
- git push -f origin $VERSION
|
||||||
rules:
|
rules:
|
||||||
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
||||||
allow_failure: true
|
|
||||||
|
Loading…
Reference in New Issue
Block a user