# # https://code.chs.usgs.gov/coupled/subtrees/phreeqc3-src # SRC 2020-12-02T18:39:55-07:00 # 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/subtrees/phreeqc3-src ## 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 # # phreeqc3/ git@${CI_SERVER_HOST}:${GROUP}/phreeqc3.git # ├─database/ ├─git@${CI_SERVER_HOST}:${GROUP}/subtrees/phreeqc3-database.git database # ├─doc/ ├─git@${CI_SERVER_HOST}:${GROUP}/subtrees/phreeqc3-doc.git doc # ├─examples/ ├─git@${CI_SERVER_HOST}:${GROUP}/subtrees/phreeqc3-examples.git examples # └─src/ └─git@${CI_SERVER_HOST}:${GROUP}/subtrees/phreeqc3-src.git src # └─common/ └─git@${CI_SERVER_HOST}:${GROUP}/subtrees/phreeqc3-src-common.git src/common git_subtree() { git subtree "${1}" --prefix="${2}" "${4}" master 2>&1 | grep -v "^[[:digit:]].*/[[:digit:]].*" } declare -A urls=( \ ["phreeqc3-src-common"]="git@${CI_SERVER_HOST}:${GROUP}/subtrees/phreeqc3-src-common.git" \ ) declare -A prefixes=( \ ["phreeqc3-src-common"]="common" \ ) export GIT_EDITOR=true for remote in "${!urls[@]}"; do git_subtree "pull" "${prefixes[$remote]}" "$remote" "${urls[$remote]}" done for remote in "${!urls[@]}"; do git_subtree "push" "${prefixes[$remote]}" "$remote" "${urls[$remote]}" done git push origin master git status trigger-downstream: stage: trigger ## ## Only run if on the master branch and the variable GROUP is set ## ## change this to ## only: ## - master@$GROUP/subtrees/phreeqc3-src ## and set GROUP to coupled before merge only: refs: - master variables: - $GROUP ## Downstream Projects ## triggers and ids are stored at the group level ## iphreeqc-src https://code.chs.usgs.gov/coupled/subtrees/iphreeqc-src ## phreeqc3 https://code.chs.usgs.gov/coupled/phreeqc3 script: - echo triggering iphreeqc-src - curl -X POST -F token=${IPHREEQC_SRC_TRIGGER} -F ref=master https://code.chs.usgs.gov/api/v4/projects/${IPHREEQC_SRC_ID}/trigger/pipeline - echo triggering phreeqc3 - curl -X POST -F token=${PHREEQC3_TRIGGER} -F ref=master https://code.chs.usgs.gov/api/v4/projects/${PHREEQC3_ID}/trigger/pipeline ## Upstream Projects ## phreeqc3-src-common https://code.chs.usgs.gov/coupled/subtrees/phreeqc3-src-common