-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
59 lines (51 loc) · 2.14 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
default:
image: python:3.9-slim
variables:
OS_AUTH_TYPE: v3applicationcredential
OS_AUTH_URL: https://hdf-cloud.fz-juelich.de:5000
OS_IDENTITY_API_VERSION: 3
OS_REGION_NAME: "HDFCloud"
OS_INTERFACE: public
PRODUCTION_IP: 134.94.199.17
PRODUCTION_NAME: model-repo
VOLUME_ID: 615f3f9d-ec7d-4860-8d65-6121ec5e01fc
# before script copied from gitlab docs
.before_script_template: &ssh_setup
before_script:
- 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client gcc libxslt-dev libffi-dev libssl-dev build-essential python3-dev -y )'
stages:
- deploy
- test-deployment
- publish
full-deploy-production:
stage: deploy
environment: Production
only:
- web
<<: *ssh_setup
script:
- echo "Starting the full testing deployment of model repo."
- pip install python-openstackclient
- sed -i "s/SOME_PASS/$DB_PASS/" deployment/cloudinit.yml
- sed -i "s/SOME_ROOT_PASS/$DB_ROOT_PASS/" deployment/cloudinit.yml
- INSTANCE_ID=`openstack server create -f value -c id --prefix IMAGE_ --flavor s2 --image 0cdff7de-8777-492b-8b38-b6a628c266d4 --user-data deployment/cloudinit.yml --security-group ssh --security-group www --security-group https $PRODUCTION_NAME`
- echo "Instance $INSTANCE_ID created"
- while [ "`openstack server show $INSTANCE_ID -c addresses -f value`" = "{}" ]; do sleep 5; done # wait until an address is available to attach the floating ip
- echo "Attaching $PRODUCTION_IP to $INSTANCE_ID"
- openstack server add floating ip $INSTANCE_ID $PRODUCTION_IP
- echo "Attaching $VOLUME_ID to $INSTANCE_ID"
- openstack server add volume $INSTANCE_ID $VOLUME_ID
- sleep 20 # apparently it may take some time until the volume is available to the OS
publishgit-do:
stage: publish
only:
- tags
tags: [stable]
script:
- apt-get update
- apt-get install -y git
- (git remote rm gith) || echo "Not found"
- (git remote -v | grep gith) || git remote add gith "https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/eflows4hpc/model-repository.git"
- git remote -v
- git fetch --unshallow origin
- git push gith +HEAD:refs/heads/main