Update .gitlab/.gitlab-ci.yml file

This commit is contained in:
Zakary Timson 2023-06-07 22:22:39 +00:00
parent 96c94d73c8
commit 18904dcb24

View File

@ -58,8 +58,8 @@ registry:
policy: pull policy: pull
before_script: before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_JOB_TOKEN $CI_REGISTRY - docker login -u $CI_REGISTRY_USER -p $CI_JOB_TOKEN $CI_REGISTRY
script:
- TAG=$([ "$CI_COMMIT_BRANCH" = "$CI_DEFAULT_BRANCH" ] && echo "latest" || echo "$CI_COMMIT_BRANCH" | sed -E "s/[_/]/-/g") - TAG=$([ "$CI_COMMIT_BRANCH" = "$CI_DEFAULT_BRANCH" ] && echo "latest" || echo "$CI_COMMIT_BRANCH" | sed -E "s/[_/]/-/g")
script:
- docker build --no-cache -t "$CI_REGISTRY_IMAGE:$TAG" . - docker build --no-cache -t "$CI_REGISTRY_IMAGE:$TAG" .
- docker push "$CI_REGISTRY_IMAGE:$TAG" - docker push "$CI_REGISTRY_IMAGE:$TAG"
allow_failure: true allow_failure: true
@ -74,24 +74,28 @@ tag:
cache: [] cache: []
before_script: before_script:
- git remote set-url origin "https://ReleaseBot:$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:]\.\/\-]+') - VERSION=$(cat package.json | grep version | grep -Eo ':.+' | grep -Eo '[[:alnum:]\.\/\-]+')
script:
- git tag -f $VERSION $CI_COMMIT_SHA - git tag -f $VERSION $CI_COMMIT_SHA
- git push -f origin $VERSION - git push -f origin $VERSION
allow_failure: true allow_failure: true
rules: rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
swarm: production:
stage: deploy stage: deploy
image: docker image: docker
cache: [] cache: []
variables: variables:
SERVICE_NAME: legio-xxx_web SERVICE_NAME: legio-xxx_web
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_JOB_TOKEN $CI_REGISTRY
- TAG=$([ "$CI_COMMIT_BRANCH" = "$CI_DEFAULT_BRANCH" ] && echo "latest" || echo "$CI_COMMIT_BRANCH" | sed -E "s/[_/]/-/g")
script: script:
- SCALE=$(docker service inspect "$SERVICE_NAME" | grep -m 1 Replicas | grep -oE "[0-9]") - docker pull "$CI_REGISTRY_IMAGE:$TAG"
- docker service update --force --with-registry-auth --image "$CI_REGISTRY_IMAGE:latest" "$SERVICE_NAME" || echo "Continuing in background" - docker service update --force --with-registry-auth --image "$CI_REGISTRY_IMAGE:$TAG" "$SERVICE_NAME" || echo "Continuing in background"
- docker service scale "$SERVICE_NAME=0" && docker service scale "$SERVICE_NAME=$SCALE"
allow_failure: true allow_failure: true
rules: rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'