forked from MSU-NatSci/DomainAccessibilityAudit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
50 lines (44 loc) · 1.56 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
image: docker:stable
services:
- docker:dind
stages:
- build
- deploy
variables:
CONTAINER_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
REPO_PATH: "/home/deploy/DomainAccessibilityAudit"
CONNECT: "[email protected]"
build:
stage: build
tags:
- msul
only:
- master
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build --pull -t $CONTAINER_IMAGE .
- docker push $CONTAINER_IMAGE
deploy:
stage: deploy
environment:
name: prod
url: "https://da11y.lib.msu.edu"
tags:
- msul
only:
- master
when: manual
script:
- ssh $CONNECT git -C $REPO_PATH reset HEAD --hard
- ssh $CONNECT git -C $REPO_PATH fetch gitlab
- ssh $CONNECT git -C $REPO_PATH checkout $CI_COMMIT_SHORT_SHA
- ssh $CONNECT "sed -i 's|^\( *\)accessibility_audit:$|&\n\1 image:\ registry.gitlab.msu.edu\/msu-libraries\/devops\/domainaccessibilityaudit:$CI_COMMIT_SHORT_SHA|' $REPO_PATH/docker-compose.yml"
- ssh $CONNECT docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- ssh $CONNECT "(cd $REPO_PATH && docker-compose -f $REPO_PATH/docker-compose.yml config)"
- ssh $CONNECT "(cd $REPO_PATH && docker-compose -f $REPO_PATH/docker-compose.yml pull)"
- ssh $CONNECT sudo /bin/systemctl restart daa
- sleep 30
- ssh $CONNECT sudo /bin/systemctl status daa
- ssh $CONNECT docker container prune -f
- ssh $CONNECT docker image prune -f -a
- ssh $CONNECT "[[ $( curl -s -o /dev/null -k -I -w \"%{http_code}\" $CI_ENVIRONMENT_URL ) -eq 200 ]]"