Added redeploy
This commit is contained in:
parent
3ce0f7a418
commit
96c94d73c8
@ -1,5 +1,11 @@
|
||||
image: node:16
|
||||
|
||||
stages:
|
||||
- build
|
||||
- test
|
||||
- publish
|
||||
- deploy
|
||||
|
||||
npm:
|
||||
stage: build
|
||||
cache:
|
||||
@ -43,7 +49,7 @@ audit:
|
||||
- if: $CI_COMMIT_BRANCH
|
||||
|
||||
registry:
|
||||
stage: deploy
|
||||
stage: publish
|
||||
image: docker
|
||||
cache:
|
||||
- key: $CI_PIPELINE_ID
|
||||
@ -56,12 +62,12 @@ registry:
|
||||
- TAG=$([ "$CI_COMMIT_BRANCH" = "$CI_DEFAULT_BRANCH" ] && echo "latest" || echo "$CI_COMMIT_BRANCH" | sed -E "s/[_/]/-/g")
|
||||
- docker build --no-cache -t "$CI_REGISTRY_IMAGE:$TAG" .
|
||||
- docker push "$CI_REGISTRY_IMAGE:$TAG"
|
||||
allow_failure: true
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH
|
||||
allow_failure: true
|
||||
|
||||
tag:
|
||||
stage: deploy
|
||||
stage: publish
|
||||
image:
|
||||
name: alpine/git
|
||||
entrypoint: [""]
|
||||
@ -72,5 +78,20 @@ tag:
|
||||
- VERSION=$(cat package.json | grep version | grep -Eo ':.+' | grep -Eo '[[:alnum:]\.\/\-]+')
|
||||
- git tag -f $VERSION $CI_COMMIT_SHA
|
||||
- git push -f origin $VERSION
|
||||
allow_failure: true
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
||||
|
||||
swarm:
|
||||
stage: deploy
|
||||
image: docker
|
||||
cache: []
|
||||
variables:
|
||||
SERVICE_NAME: legio-xxx_web
|
||||
script:
|
||||
- SCALE=$(docker service inspect "$SERVICE_NAME" | grep -m 1 Replicas | grep -oE "[0-9]")
|
||||
- docker service update --force --with-registry-auth --image "$CI_REGISTRY_IMAGE:latest" "$SERVICE_NAME" || echo "Continuing in background"
|
||||
- docker service scale "$SERVICE_NAME=0" && docker service scale "$SERVICE_NAME=$SCALE"
|
||||
allow_failure: true
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
||||
|
Loading…
Reference in New Issue
Block a user