-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy path.gitlab-ci.yml
110 lines (104 loc) · 5.04 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
stages:
- test
- deploy
variables:
NVM_VERSION: 0.39.5
NODE_VERSION: 16.0.0
test:
stage: test
image: ubuntu:latest
before_script:
- apt-get update
- apt-get upgrade -y
- apt-get install -y tzdata
- apt-get install -y wget
- apt-get install -y git
- apt-get install -y curl bzip2 jq
- git submodule update --init
- wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v$NVM_VERSION/install.sh | bash
- export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
- nvm install $NODE_VERSION
- wget -O /tmp/chrome.deb https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
- apt-get install -y /tmp/chrome.deb
- cd lib/jsorolla && npm install phantomjs-prebuilt && npm install && cd ../.. && npm install --legacy-peer-deps
- npm install -g grunt-cli
- apt-get install xvfb && Xvfb :99 & export DISPLAY=:99
script:
- |
for i in {1..5}; do
echo "Finding Github CI status for ${CI_COMMIT_SHA}..." && export GITHUB_CI_STATUS=$(curl -s https://api.github.com/repos/EBIVariation/eva-web/actions/runs | jq --arg COMMIT_TO_FIND $CI_COMMIT_SHA -r '.workflow_runs | map(select(.head_sha == $COMMIT_TO_FIND and .conclusion == "success"))[0].conclusion') && [[ $GITHUB_CI_STATUS == "success" ]] && echo "Github CI run was successful!"
if [ $? -ne 0 ]; then
echo "Retrying..."
sleep 300
else
exit 0
fi
done
exit 1
environment:
name: test-env
only:
- master
- tags
# Not executed, parent job definition
.deploy-website:
stage: deploy
image: ubuntu:latest
environment:
name: $ENVIRONMENT_NAME
before_script:
- apt-get update
- apt-get upgrade -y
- apt-get install -y tzdata
- apt-get install -y wget
- apt-get install -y git
- apt-get install -y zip
- apt-get install -y rsync
- apt-get install -y curl bzip2 jq
- git submodule update --init
- wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v$NVM_VERSION/install.sh | bash
- export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" && [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
- nvm install $NODE_VERSION
- cd lib/jsorolla && npm install phantomjs-prebuilt && npm install && cd ../.. && npm install --legacy-peer-deps
- npm install -g grunt-cli
- grunt --env=$ENVIRONMENT_NAME
- ARTIFACT_NAME=$(basename $(ls -d build/*$ENVIRONMENT_NAME))
# Start ssh-agent and set identity then copy the file to website mount point and a compressed version to cluster
# See https://docs.gitlab.com/ee/ci/ssh_keys/
- apt-get -y install openssh-client
- eval "$(ssh-agent)"
- echo "$EVA_ETL_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- zip -q -r build/${ARTIFACT_NAME}.zip build/${ARTIFACT_NAME}
- scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null build/${ARTIFACT_NAME}.zip ${CLUSTER_USER}@${CLUSTER_LOGIN_NODE_CODON}:${EVA_SOFTWARE_PATH_CODON}/eva-web/
- echo "$VAR_ADM_PRIVATE_KEY" | tr -d '\r' | ssh-add -
dependencies:
- test
deploy-website-internal:
extends: .deploy-website
variables:
ENVIRONMENT_NAME: dev
WEBSITE_DEPLOY_ENVIRONMENT: dev
script:
- rsync -av -q -e "ssh -o PubKeyAcceptedKeyTypes=+ssh-rsa -o HostKeyAlgorithms=+ssh-dss -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" build/${ARTIFACT_NAME}/* ${WEBSITE_DEPLOY_USER}@${WEBSITE_DEPLOY_NODE_INTERNAL}:${WEBSITE_DEPLOY_PATH}/${WEBSITE_DEPLOY_ENVIRONMENT}/www/
only:
- master
deploy-website-development:
extends: .deploy-website
variables:
ENVIRONMENT_NAME: staging
WEBSITE_DEPLOY_ENVIRONMENT: stage
script:
- rsync -av -q -e "ssh -o PubKeyAcceptedKeyTypes=+ssh-rsa -o HostKeyAlgorithms=+ssh-dss -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" build/${ARTIFACT_NAME}/* ${WEBSITE_DEPLOY_USER}@${WEBSITE_DEPLOY_NODE_STAGING_MAIN}:${WEBSITE_DEPLOY_PATH}/${WEBSITE_DEPLOY_ENVIRONMENT}/www/
- rsync -av -q -e "ssh -o PubKeyAcceptedKeyTypes=+ssh-rsa -o HostKeyAlgorithms=+ssh-dss -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" build/${ARTIFACT_NAME}/* ${WEBSITE_DEPLOY_USER}@${WEBSITE_DEPLOY_NODE_STAGING_FALLBACK}:${WEBSITE_DEPLOY_PATH}/${WEBSITE_DEPLOY_ENVIRONMENT}/www/
only:
- master
deploy-website-production:
extends: .deploy-website
variables:
ENVIRONMENT_NAME: prod
WEBSITE_DEPLOY_ENVIRONMENT: prod
script:
- rsync -av -q -e "ssh -o PubKeyAcceptedKeyTypes=+ssh-rsa -o HostKeyAlgorithms=+ssh-dss -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" build/${ARTIFACT_NAME}/* ${WEBSITE_DEPLOY_USER}@${WEBSITE_DEPLOY_NODE_PROD_MAIN}:${WEBSITE_DEPLOY_PATH}/${WEBSITE_DEPLOY_ENVIRONMENT}/www/
- rsync -av -q -e "ssh -o PubKeyAcceptedKeyTypes=+ssh-rsa -o HostKeyAlgorithms=+ssh-dss -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" build/${ARTIFACT_NAME}/* ${WEBSITE_DEPLOY_USER}@${WEBSITE_DEPLOY_NODE_PROD_FALLBACK}:${WEBSITE_DEPLOY_PATH}/${WEBSITE_DEPLOY_ENVIRONMENT}/www/
only:
- tags