-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
73 lines (69 loc) · 3.09 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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
70
71
72
73
default:
interruptible: false
stages:
- tag
- build
- deploy
######
# Tag stage
tag:
image: harbor.containers.wurnet.nl/proxy-cache/library/node:14.18-buster-slim
stage: tag
before_script:
- apt-get update && apt-get install -y --no-install-recommends git-core ca-certificates
- 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
only:
- main
except:
refs:
- tags
variables:
- $CI_COMMIT_TITLE =~ /^RELEASE:.+$/
######
# build stage
# build a new container and push to harbor
build:
stage: build
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
when: on_success
script:
- mkdir -p /kaniko/.docker
- "export CI_JOB_NAME_SHORT=$(echo $CI_JOB_NAME | cut -d : -f 2-)"
- echo "{\"auths\":{\"$HARBOR_REGISTRY\":{\"username\":\"$HARBOR_USER\",\"password\":\"$HARBOR_PASSWORD\"}}}" > /kaniko/.docker/config.json
- echo "build; $CI_COMMIT_TAG/$CI_COMMIT_SHORT_SHA/$CI_COMMIT_REF_NAME"
#- /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
- if [ -z $CI_COMMIT_TAG ]; then /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $HARBOR_REGISTRY/$HARBOR_PROJECT/metadata-augmentation:$CI_COMMIT_SHORT_SHA --destination $HARBOR_REGISTRY/$HARBOR_PROJECT/metadata-augmentation:latest; else /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR --destination $HARBOR_REGISTRY/$HARBOR_PROJECT/metadata-augmentation:$CI_COMMIT_TAG --destination $HARBOR_REGISTRY/$HARBOR_PROJECT/metadata-augmentation:latest; fi
only:
- develop
- tags
deploy-dev:
stage: deploy
image: harbor.containers.wurnet.nl/proxy-cache/library/alpine:3
before_script:
- apk add curl
script:
- echo "deploy-dev; $CI_COMMIT_SHORT_SHA/$CI_COMMIT_REF_NAME"
- 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]=metadata-augmentation" https://git.wur.nl/api/v4/projects/7515/trigger/pipeline
only:
- develop
environment:
name: dev
url: https://trans.soilwise.containers.wurnet.nl
deploy-prod:
stage: deploy
image: harbor.containers.wurnet.nl/proxy-cache/library/alpine:3
before_script:
- apk add curl
script:
- echo "deploy-prod; $CI_COMMIT_TAG/$CI_COMMIT_REF_NAME"
# - curl -X POST -F token=${DEPLOY_TOKEN} -F "ref=master" -F "variables[VERSION_TAG]=${CI_COMMIT_TAG}" -F "variables[ENVIRONMENT]=prod" -F "variables[PROJECT]=metadata-augmentation" https://git.wur.nl/api/v4/projects/7515/trigger/pipeline
only:
- tags
environment:
name: Production
url: https://trans.soilwise.containers.wur.nl