-
Notifications
You must be signed in to change notification settings - Fork 3
130 lines (109 loc) · 3.88 KB
/
tutor.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: CI
on:
push:
branches: [ "main" ]
workflow_dispatch:
inputs:
skip_build_openedx_job:
required: true
type: boolean
default: true
skip_build_mfe_job:
required: true
type: boolean
default: true
env:
DOCKER_BUILDX: "1"
SERVER_IP: babilonia.abzt.de
TUTOR_ROOT: ${{ github.repository }}
TUTOR_PLUGINS_ROOT: $TUTOR_ROOT/plugins
OPENEDX_CACHE_IMAGE: docker.io/abstract2tech/community-theme-openedx-cache
MFE_CACHE_IMAGE: docker.io/abstract2tech/community-theme-mfe-cache
jobs:
build-openedx:
env:
OPENEDX_IMAGE: docker.io/abstract2tech/community-theme-openedx:16.1.0
runs-on: ubuntu-latest
if : ${{ !inputs.skip_build_openedx_job }}
steps:
- uses: actions/checkout@v3
- name: Export TUTOR_ variables
run: |
echo "TUTOR_ROOT=${GITHUB_WORKSPACE}" >> ${GITHUB_ENV}
echo "TUTOR_PLUGINS_ROOT=${GITHUB_WORKSPACE}/plugins" >> ${GITHUB_ENV}
echo "TUTOR_APP=community-theme" >> ${GITHUB_ENV}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Docker buildx
run: docker buildx create --use
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install requirements
run: pip install -r requirements.txt
- name: Generate tutor env
run: tutor config save
- name: Build tutor openedx image
run: |
docker login -u abstract2tech -p ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
tutor images build openedx
tutor images push openedx
build-mfe:
runs-on: ubuntu-latest
env:
MFE_IMAGE: docker.io/abstract2tech/community-theme-mfe:16.1.0
steps:
- uses: actions/checkout@v3
- name: Export TUTOR_ variables
run: |
echo "TUTOR_ROOT=${GITHUB_WORKSPACE}" >> ${GITHUB_ENV}
echo "TUTOR_PLUGINS_ROOT=${GITHUB_WORKSPACE}/plugins" >> ${GITHUB_ENV}
echo "TUTOR_APP=community-theme" >> ${GITHUB_ENV}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install requirements
run: pip install -r requirements.txt
- name: Docker buildx
run: docker buildx create --use
- name: Generate tutor env
run: tutor config save
- name: Build tutor MFE image
run: |
docker login -u abstract2tech -p ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
tutor images build mfe
tutor images push mfe
deploy:
runs-on: ubuntu-latest
environment: production
if: ${{ always() && (needs.build-openedx.result == 'success' || needs.build-openedx.result == 'skipped') }}
needs: [build-openedx, build-mfe]
steps:
- uses: actions/checkout@v3
- name: Add SSH key to agent
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
ANSIBLE_VAULT_PASSWORD: ${{ secrets.ANSIBLE_VAULT_PASSWORD }}
run: |
eval $(ssh-agent)
if [ ! -d ~/.ssh ]; then
mkdir -p ~/.ssh && chmod 700 ~/.ssh
fi
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-add ~/.ssh/id_rsa
ssh-keyscan babilonia.abzt.de > ~/.ssh/known_hosts
pip install ansible==7.2.0
ansible-galaxy install -r requirements.yml -p ansible/roles/
cd $GITHUB_WORKSPACE/ansible
echo "$ANSIBLE_VAULT_PASSWORD" > vault_pass
chmod 600 vault_pass
ansible-playbook --vault-password-file ./vault_pass -u tutor -i inventory.ini -l babilonia.abzt.de --tags tutor_deploy tutor.yml