.gitlab-ci.yml 2.35 KB
Newer Older
Buskermolen, Joost's avatar
Buskermolen, Joost committed
1 2 3 4 5 6 7 8 9 10 11 12
default:
  interruptible: false
stages:
  - tag
  - publish
  - deploy

# tag release
tag:
  image: node:12-buster-slim
  stage: tag
  before_script:
13
    - apt-get update && apt-get install -y --no-install-recommends git-core git-lfs ca-certificates
Buskermolen, Joost's avatar
Buskermolen, Joost committed
14 15 16 17
    - npm install -g semantic-release @semantic-release/changelog @semantic-release/commit-analyzer @semantic-release/gitlab @semantic-release/git @semantic-release/npm @semantic-release/release-notes-generator conventional-changelog conventional-changelog-conventionalcommits 
  script:
    - semantic-release
  when: on_success
18 19
  variables:
    GIT_LFS_SKIP_SMUDGE: 1
Buskermolen, Joost's avatar
Buskermolen, Joost committed
20 21 22 23 24 25 26 27
  only:
    - master
  except:
    refs:
      - tags
    variables:
      - $CI_COMMIT_TITLE =~ /^RELEASE:.+$/

28

Buskermolen, Joost's avatar
Buskermolen, Joost committed
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
# build a new container
build:
  stage: publish
  image:
    name: gcr.io/kaniko-project/executor:debug
    entrypoint: [""]
  when: on_success
  script:
    - mkdir -p /kaniko/.docker
    - echo "{\"auths\":{\"$HARBOR_REGISTRY\":{\"username\":\"$HARBOR_USER\",\"password\":\"$HARBOR_PASSWORD\"}}}" > /kaniko/.docker/config.json
    - if [ -z $flag ]; then /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $HARBOR_REGISTRY/$HARBOR_PROJECT/$CI_PROJECT_NAME:$CI_COMMIT_SHORT_SHA; else /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $HARBOR_REGISTRY/$HARBOR_PROJECT/$CI_PROJECT_NAME:$CI_COMMIT_TAG --destination $HARBOR_REGISTRY/$HARBOR_PROJECT/$CI_PROJECT_NAME:latest; fi
  only:
    - tags
    - develop

deploy-dev:
  stage: deploy
  image: alpine:latest
  before_script:
    - apk add curl
  script: curl -X POST -F token=${DEPLOY_TOKEN} -F "ref=master" -F "variables[VERSION_TAG]=${CI_COMMIT_SHORT_SHA}" -F "variables[ENVIRONMENT]=dev" -F "variables[PROJECT]=leuven" https://git.wur.nl/api/v4/projects/7515/trigger/pipeline
  only:
    - tags
    - develop
  environment:
    name: Development
    url: https://leuven.containers.wur.nl

deploy-prod:
  stage: deploy
  image: alpine:latest
  before_script:
    - apk add curl
  script: curl -X POST -F token=${DEPLOY_TOKEN} -F "ref=master" -F "variables[VERSION_TAG]=${CI_COMMIT_TAG}" -F "variables[ENVIRONMENT]=prod" -F "variables[PROJECT]=leuven" https://git.wur.nl/api/v4/projects/7515/trigger/pipeline
  only:
    - tags
    - master
  #when: manual
  environment:
    name: Production
    url: https://leuven.isric.org