forked from PRIDE-Archive/nf-downloadstats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
33 lines (28 loc) · 1.51 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
image: maven:3.3.9-jdk-8-alpine
deploy:
environment: prod
before_script:
- apk add --update openssh-client bash openssl rsync gettext tzdata
- eval $(ssh-agent -s)
- mkdir ~/.ssh
- chmod 700 ~/.ssh
- echo $SSH_KEY | base64 -d | tr -d '\r' | ssh-add - > /dev/null
- DEPLOY_SERVERS_ARRAY=(`echo $DEPLOY_SERVER | tr ',' ' '`)
- for i in "${DEPLOY_SERVERS_ARRAY[@]}"; do ssh-keyscan $i >> ~/.ssh/known_hosts; chmod 600 ~/.ssh/*; done
script:
- DEPLOY_DIR=$(date +"%Y%m%d_%H%M%S")
- mkdir $DEPLOY_DIR
# Substitute environment variables
- envsubst < .params.config > params.config
- envsubst '${PIPELINE_BASE_DIR},${LOG_FOLDER},${DATA_ROOT_DIR},${API_ENDPOINT_FILE_DOWNLOADS_PER_PROJECT},${API_ENDPOINT_FILE_DOWNLOADS_PER_FILE},${API_ENDPOINT_HEADER}' < scripts/.run_stat.sh > scripts/run_stat.sh
- envsubst '${CONDA_INIT},${LOGS_SOURCE_ROOT},${LOGS_DESTINATION_ROOT},${PROFILE},${RESOURCE}' < .run_file_download_stats.sh > run_file_download_stats.sh
# Move all necessary files to the deployment directory
- rsync -a scripts *.config *.yml *.nf *.sh filedownloadstat conf params template "$DEPLOY_DIR/"
# Secure permissions
- cd $DEPLOY_DIR && chmod 755 *.sh scripts/* && cd ..
# Deploy to HPC
- ssh $SERVER_USER@$DEPLOY_SERVER "bash && mkdir -p $DEPLOY_PATH"
- rsync -a $DEPLOY_DIR $SERVER_USER@$DEPLOY_SERVER:$DEPLOY_PATH/
- ssh $SERVER_USER@$DEPLOY_SERVER "bash && cd $DEPLOY_PATH && ln -snf $DEPLOY_DIR $SYMLINK"
when: manual
allow_failure: false