-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy path.gitlab-ci.yml
97 lines (87 loc) · 2.57 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
image: mcr.microsoft.com/dotnet/sdk:latest
stages:
- test
- build
- push
- release
variables:
BUILD_CONFIGURATION: 'Release'
OBJECTS_DIRECTORY: 'obj'
NUGET_PACKAGES_DIRECTORY: '.nuget'
SOURCE_CODE_PATH: '*/*/'
cache:
key: "$CI_JOB_STAGE-$CI_COMMIT_REF_SLUG"
paths:
- '$SOURCE_CODE_PATH$OBJECTS_DIRECTORY/project.assets.json'
- '$SOURCE_CODE_PATH$OBJECTS_DIRECTORY/*.csproj.nuget.*'
- '$NUGET_PACKAGES_DIRECTORY'
policy: pull-push
before_script:
- 'docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY'
test:
stage: test
script:
- 'dotnet restore'
- 'dotnet test'
build:
stage: build
script:
- 'docker build -t $CI_REGISTRY_IMAGE:dev -t $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA -f WeddingShare/Dockerfile .'
- 'docker push $CI_REGISTRY_IMAGE:dev'
- 'docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA'
needs:
- test
push_pre_release:
variables:
GIT_STRATEGY: none
stage: push
only:
- /^(prerel|rc|release)-[0-9]+\.[0-9]+\.[0-9]+$/
script:
- 'docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA'
- 'docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA $CI_REGISTRY_IMAGE:$CI_COMMIT_BRANCH'
- 'docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_BRANCH'
- 'docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA $CI_REGISTRY_IMAGE:pre_release'
- 'docker push $CI_REGISTRY_IMAGE:pre_release'
needs:
- build
push_latest:
variables:
GIT_STRATEGY: none
stage: push
only:
- main
- master
script:
- 'docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA'
- 'docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA $CI_REGISTRY_IMAGE:latest'
- 'docker push $CI_REGISTRY_IMAGE:latest'
needs:
- build
push_tag:
variables:
GIT_STRATEGY: none
stage: push
only:
- tags
script:
- 'docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA'
- 'docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME'
- 'docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME'
needs:
- build
push_docker_hub:
variables:
GIT_STRATEGY: none
stage: push
only:
- tags
script:
- 'docker pull $CI_REGISTRY_IMAGE:latest'
- 'docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_TOKEN'
- 'docker tag $CI_REGISTRY_IMAGE:latest $DOCKERHUB_USERNAME/wedding_share:latest'
- 'docker push $DOCKERHUB_USERNAME/wedding_share:latest'
- 'docker tag $CI_REGISTRY_IMAGE:latest $DOCKERHUB_USERNAME/wedding_share:$CI_COMMIT_REF_NAME'
- 'docker push $DOCKERHUB_USERNAME/wedding_share:$CI_COMMIT_REF_NAME'
needs:
- build