-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path.gitlab-ci.yml
89 lines (79 loc) · 2.3 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
stages:
- build
- deploy
workflow:
rules:
- when: always
image: docker.io/abstract2tech/tutor-ci:17.0.4
services:
- docker:23-dind
variables:
DOCKER_HOST: tcp://docker:2375/
DOCKER_TLS_CERTDIR: ""
GIT_LFS_SKIP_SMUDGE: "1"
DOCKER_BUILDKIT: "1"
.build-prepare: &build-prepare
- export TUTOR_ROOT="$(pwd)"
- export TUTOR_PLUGINS_ROOT="${TUTOR_ROOT}/plugins"
- pip install -r requirements.txt
- docker buildx create --use
- docker login -u "${REGISTRY_USERNAME}" -p "${REGISTRY_PASSWORD}"
- yq eval 'keys | .[] | select(. == "*_MFE_APP")' config.yml | xargs -I {} yq -i ".{}.version = \"${CI_COMMIT_BRANCH}\"" config.yml
- tutor config save
.build-execute-openedx: &build-execute-openedx
- tutor images build openedx --build-arg --cache-from --build-arg "${OPENEDX_IMAGE}":-cache --cache-to-registry
- tutor images push openedx
.build-execute-mfe: &build-execute-mfe
- tutor images build mfe --build-arg --cache-from --build-arg "${MFE_IMAGE}":-cache --cache-to-registry
- tutor images push mfe
.deploy-prepare: &deploy-prepare
- eval $(ssh-agent -s)
- mkdir -p ~/.ssh && chmod 700 ~/.ssh
- cp "${SSH_KNOWN_HOSTS}" ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- echo "${SSH_PRIVATE_KEY}" | ssh-add -
- pip install ansible==7.2.0
- ansible-galaxy install -r ansible/requirements.yml
- cd "${CI_PROJECT_DIR}"/ansible
- cp "${ANSIBLE_VAULT_PASSWORD}" vault_pass
- chmod 600 vault_pass
.deploy-execute: &deploy-execute
- cd "${CI_PROJECT_DIR}"/ansible
- ANSIBLE_CONFIG=. ansible-playbook -u tutor -l "${ANSIBLE_HOST}" -t tutor_config playbook.yml
- ANSIBLE_CONFIG=. ansible-playbook -u tutor -l "${ANSIBLE_HOST}" -t tutor_service,tutor_deploy playbook.yml
build-openedx:
stage: build
tags:
- did
variables:
OPENEDX_IMAGE: docker.io/abstract2tech/community-theme-openedx:16.1.0
before_script:
- *build-prepare
script:
- *build-execute-openedx
only:
- main
build-mfe:
stage: build
tags:
- did
variables:
MFE_IMAGE: docker.io/abstract2tech/community-theme-mfe:16.1.0
before_script:
- *build-prepare
script:
- *build-execute-mfe
only:
- main
deploy:
stage: deploy
tags:
- docker
variables:
ANSIBLE_HOST: community_theme
before_script:
- *deploy-prepare
script:
- *deploy-execute
only:
- main