-
Notifications
You must be signed in to change notification settings - Fork 63
/
.gitlab-ci.yml
83 lines (74 loc) · 2.82 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
image: docker:stable
services:
- docker:dind
stages:
- build
- release
- trigger
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_DRIVER: overlay2
CONTAINER_IMAGE: registry.gitlab.com/hibou-io/hibou-odoo/suite
DOCKERHUB_IMAGE: hibou/hibou-odoo-suite
GITLAB_BASE_URL: https://gitlab.com
ENTERPRISE_PROJECT_ID: 40326521
before_script:
- RELEASE=$(echo $CI_COMMIT_REF_NAME | sed "s{.*\/\(.*\)\/.*{\1{g")
- RELEASE_DATE="$(date '+%Y-%m-%d')"
- IMAGE_TAG=$(echo $CI_COMMIT_REF_SLUG | sed "s/^\([[:digit:]][[:digit:]]\)-\([[:digit:]]\)/\1\.\2/g")
- IMAGE_TAG_DATE="${IMAGE_TAG}-${RELEASE_DATE}"
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
merge_request:
variables:
GIT_STRATEGY: none
stage: build
only:
- /(^add\/)|(^new\/)|(^mig\/)|(^imp\/)|(^fix\/)/i
script:
- docker pull registry.gitlab.com/hibou-io/hibou-odoo/flow
- docker tag registry.gitlab.com/hibou-io/hibou-odoo/flow flow
- ENVS=`env | grep "CI_\|GITLAB_" | sed -n '/^[^\t]/s/=.*//p' | sed '/^$/d' | sed 's/^/-e /g' | tr '\n' ' '`
- docker run $ENVS flow gitlab-automerge --target-branch "${RELEASE}-test" --automerge
- docker run $ENVS flow gitlab-automerge --remove-source
build:
variables:
GIT_SUBMODULE_STRATEGY: recursive
stage: build
script:
- sed -i "s/RELEASE/$RELEASE/g" Dockerfile-GitLab
- docker build --pull -t $CONTAINER_IMAGE:$IMAGE_TAG -f Dockerfile-GitLab .
- docker push $CONTAINER_IMAGE:$IMAGE_TAG
release:
stage: release
variables:
GIT_STRATEGY: none
script:
- apk add python3
- docker pull registry.gitlab.com/hibou-io/hibou-odoo/flow
- docker tag registry.gitlab.com/hibou-io/hibou-odoo/flow flow
- docker run -v "${PWD}/.local:/dest" flow self-install /dest
- cd .local/flow
- ./entrypoint.sh docker-release $CONTAINER_IMAGE:$IMAGE_TAG $CONTAINER_IMAGE:$IMAGE_TAG_DATE
- docker login -u "${DOCKERHUB_USERNAME}" -p "${DOCKERHUB_PASSWORD}"
- docker tag $CONTAINER_IMAGE:$IMAGE_TAG $DOCKERHUB_IMAGE:$IMAGE_TAG
- docker push $DOCKERHUB_IMAGE:$IMAGE_TAG
- ./entrypoint.sh docker-release $DOCKERHUB_IMAGE:$IMAGE_TAG $DOCKERHUB_IMAGE:$IMAGE_TAG_DATE
only:
- /^\d+\.\d+$/
publish:
stage: build
script:
- docker pull registry.gitlab.com/hibou-io/hibou-odoo/flow
- docker tag registry.gitlab.com/hibou-io/hibou-odoo/flow flow
- ENVS=`env | grep "CI_\|GITLAB_" | sed -n '/^[^\t]/s/=.*//p' | sed '/^$/d' | sed 's/^/-e /g' | tr '\n' ' '`
- docker run -v $PWD:/src $ENVS flow odoo-publish -n "Hibou Odoo Suite" -v $RELEASE
only:
- /^\d\d\.\d/
trigger:
variables:
GIT_STRATEGY: none
stage: trigger
script:
- docker run byrnedo/alpine-curl curl --request POST --form "token=$CI_JOB_TOKEN" --form ref=$RELEASE $GITLAB_BASE_URL/api/v4/projects/$ENTERPRISE_PROJECT_ID/trigger/pipeline
only:
- /^\d\d\.\d/