forked from usgs-coupled/phreeqcrm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
119 lines (103 loc) · 3.95 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
111
112
113
114
115
116
117
118
119
#
# https://code.chs.usgs.gov/coupled/phreeqcrm
# SRC 2020-01-28T10:03:39-07:00
# SRC 2021-10-31T11:57:41-06:00 -- changed pull to squash -- HEAD:b74733e436f6b7a67f5e84ad0554ffe79a1c2e82
#
image: ${CI_REGISTRY}/coupled/containers/buildpack-deps:bionic-scm
stages:
- sync
- trigger
before_script:
- eval $(ssh-agent -s)
- echo "${SSH_PRIVATE_KEY_ENC}" | base64 --decode | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan ${CI_SERVER_HOST} >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- git config --global user.email "darth@empire.com"
- git config --global user.name "Darth Vader"
subtree-sync:
stage: sync
##
## Only run if on the master branch and the variable GROUP is set
##
## change this to
## only:
## - master@$GROUP/phreeqcrm
## and set GROUP to coupled before merge
only:
refs:
- master
variables:
- $GROUP
script:
##
## Must re-clone in order for the subtree merge to work
## tried re-setting the url for the origin but didn't work
##
- cd ..
- rm -rf ${CI_PROJECT_NAME}
- git clone git@${CI_SERVER_HOST}:${CI_PROJECT_PATH}.git
- cd ${CI_PROJECT_NAME}
##
## Sync subtrees
##
- |
#!/bin/bash -ex
#
# PhreeqcRM/ git@${CI_SERVER_HOST}:${GROUP}/phreeqcrm.git
# ├─database/ ├─git@${CI_SERVER_HOST}:${GROUP}/subtrees/phreeqc3-database.git database
# └─src/ └─git@${CI_SERVER_HOST}:${GROUP}/subtrees/PhreeqcRM-src.git src
# └─IPhreeqcPhast/ └─IPhreeqcPhast
# └─IPhreeqc/ └─git@${CI_SERVER_HOST}:${GROUP}/subtrees/IPhreeqc-src.git src/IPhreeqcPhast/IPhreeqc
# └─phreeqcpp/ └─git@${CI_SERVER_HOST}:${GROUP}/subtrees/phreeqc3-src.git src/IPhreeqcPhast/IPhreeqc/phreeqcpp
# └─common/ └─git@${CI_SERVER_HOST}:${GROUP}/subtrees/phreeqc3-src-common.git src/IPhreeqcPhast/IPhreeqc/phreeqcpp/common
git_subtree() {
git subtree "${1}" --prefix="${2}" "${4}" master 2>&1 | grep -v "^[[:digit:]].*/[[:digit:]].*"
}
declare -A urls=( \
["phreeqc3-database.git"]="git@${CI_SERVER_HOST}:${GROUP}/subtrees/phreeqc3-database.git" \
["PhreeqcRM-src.git"]="git@${CI_SERVER_HOST}:${GROUP}/subtrees/PhreeqcRM-src.git" \
)
declare -A prefixes=( \
["phreeqc3-database.git"]="database" \
["PhreeqcRM-src.git"]="src" \
)
export GIT_EDITOR=true
for remote in "${!urls[@]}"; do
#git_subtree "pull" "${prefixes[$remote]}" "$remote" "${urls[$remote]}"
git subtree pull --prefix "${prefixes[$remote]}" --squash "${urls[$remote]}" master
done
for remote in "${!urls[@]}"; do
git_subtree "push" "${prefixes[$remote]}" "$remote" "${urls[$remote]}"
done
git status
git push origin master
trigger-downstream:
stage: trigger
##
## Only run if on the master branch and the variable GROUP is set
##
## change this to
## only:
## - master@$GROUP/phreeqcrm
## and set GROUP to coupled before merge
only:
refs:
- master
variables:
- $GROUP
## Downstream Projects
## triggers and ids are stored at the group level
## phast3 https://code.chs.usgs.gov/coupled/phast3
## vs2drt-src https://code.chs.usgs.gov/coupled/subtrees/vs2drt-src
script:
- echo triggering phast3
- curl -X POST -F token=${PHAST3_TRIGGER} -F ref=master https://code.chs.usgs.gov/api/v4/projects/${PHAST3_ID}/trigger/pipeline
- sleep 360
- echo triggering vs2drt-src
- curl -X POST -F token=${VS2DRT_SRC_TRIGGER} -F ref=master https://code.chs.usgs.gov/api/v4/projects/${VS2DRT_SRC_ID}/trigger/pipeline
- sleep 120
## Upstream Projects
## phreeqcrm-src https://code.chs.usgs.gov/coupled/subtrees/phreeqcrm-src
## phreeqc3-database https://code.chs.usgs.gov/coupled/subtrees/phreeqc3-database