forked from LycheeOrg/Lychee-Docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
77 lines (67 loc) · 1.92 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
image: docker:stable
stages:
- build
- test
- release
variables:
DEV: bigrob8181/$CI_PROJECT_NAME:dev
RELEASE: bigrob8181/$CI_PROJECT_NAME:$CI_COMMIT_TAG
LATEST: bigrob8181/$CI_PROJECT_NAME:latest
#before_script:
# - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD"
# For Production
build_prod:
stage: build
script:
- docker build --pull -t $RELEASE .
only:
- tags
test_prod:
stage: test
script:
- docker run --name $CI_PROJECT_NAME'_test' -d $RELEASE
- docker ps -a | awk '{print $NF}' | grep -w $CI_PROJECT_NAME'_test' | cat
after_script:
- docker stop $CI_PROJECT_NAME'_test' && docker rm $CI_PROJECT_NAME'_test'
only:
- tags
release_prod:
stage: release
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD"
script:
- docker tag $RELEASE $LATEST
- docker push $RELEASE
- docker push $LATEST
after_script:
- apk add --upgrade python3
- python3 -m ensurepip
- rm -rf /var/cache/apk/*
- pip3 install gitlab_release
- python3 -m gitlab_release --server "$CI_PROJECT_URL" --project_id "$CI_PROJECT_ID" --release_tag "$CI_COMMIT_TAG" --zip "release-${CI_COMMIT_TAG}.zip" "$CI_PRIVATE_TOKEN" *
only:
- tags
# For Development
build_dev:
stage: build
script:
- docker build --pull -t $DEV .
only:
- master
test_dev:
stage: test
script:
- docker run --name $CI_PROJECT_NAME'_test' -d $DEV
- docker ps -a | awk '{print $NF}' | grep -w $CI_PROJECT_NAME'_test' | cat
after_script:
- docker stop $CI_PROJECT_NAME'_test' && docker rm $CI_PROJECT_NAME'_test'
only:
- master
release_dev:
stage: release
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD"
script:
- docker push $DEV
only:
- master