-
Notifications
You must be signed in to change notification settings - Fork 4
/
.gitlab-ci.yml
57 lines (47 loc) · 1.6 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
before_script:
- apk update
- apk --no-cache add py3-pip python3 curl
- python3 -m venv $HOME/.venv
- export PATH=$HOME/.venv/bin:$PATH
- pip3 install pyyaml
- curl -O https://raw.githubusercontent.com/FredHutch/swarm-build-helper/main/build_helper.py
# below is from https://stackoverflow.com/a/65810302/470769
- mkdir -p $HOME/.docker
- echo $DOCKER_AUTH_CONFIG > $HOME/.docker/config.json
- set -x
stages:
- build
- test
- deploy
build:
stage: build
script: |
# python3 build_helper.py docker-compose.yml > /dev/null
if [ "$CI_COMMIT_BRANCH" == "main" ]; then
export JEKYLL_ENV=production
else
export JEKYLL_ENV=development
fi
# build image
docker build --build-arg JEKYLL_ENV=$JEKYLL_ENV -t sc-registry.fredhutch.org/whoiswho:test .
docker push sc-registry.fredhutch.org/whoiswho:test
sleep 5
test:
stage: test
services:
- name: sc-registry.fredhutch.org/whoiswho:test
alias: whoiswho
script: |
curl -sI http://whoiswho | head -1 | grep -q "200 OK"
deploy:
stage: deploy
only:
refs:
- main
script:
- docker tag sc-registry.fredhutch.org/whoiswho:test sc-registry.fredhutch.org/whoiswho:latest
- docker push sc-registry.fredhutch.org/whoiswho:latest
- sleep 15
- echo $SC_SWARM_CICD_SSH_KEY | base64 -d > ./sc_swarm_cicd_ssh_key
- chmod 0400 ./sc_swarm_cicd_ssh_key
- python3 build_helper.py docker-compose.yml | ssh -i ./sc_swarm_cicd_ssh_key -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@sc-swarm-mgr.fhcrc.org docker stack deploy --with-registry-auth -c - whoiswho