[OCaml] High Intensity Training Online
build Export deployment version
Write the deployed short commit hash to the shared environment file and load it through systemd for the page footer.
Changed files
deploy/post-receive
@@ -100,6 +100,7 @@
100
100
printf '%s\t%s\t%ss\t%s\t%s\n' \
101
101
"${ts}" "${sha:0:12}" "${build_secs}" "${DEPLOY_BRANCH}" "${subject}" \
102
102
>>"${SHARED}/deploy-history.tsv"
103
Added:
printf 'HITO_VERSION=%s\n' "${sha:0:12}" >"${SHARED}/deploy.env"
103
104
}
104
105
105
106
# Point current at ${rel} in a single rename so no request sees a half state.
deploy/setup.sh
@@ -79,6 +79,9 @@
79
79
-e 's#^WorkingDirectory=.*#WorkingDirectory=/srv/hito/current#' \
80
80
-e 's#^Environment=HITO_DB=.*#Environment=HITO_DB=sqlite3:/srv/hito/shared/hito.sqlite#' \
81
81
"${UNIT}"
82
Added:
if ! grep -q '^EnvironmentFile=/srv/hito/shared/deploy.env$' "${UNIT}"; then
83
Added:
sed -i '/^Environment=HITO_DB=/a EnvironmentFile=/srv/hito/shared/deploy.env' "${UNIT}"
84
Added:
fi
82
85
systemctl daemon-reload
83
86
echo " unit points at current/ (backup kept alongside)"
84
87
}
@@ -139,6 +142,7 @@
139
142
printf '%s\t%s\t%ss\t%s\t%s\n' \
140
143
"${ts}" "${sha:0:12}" "${build_secs}" "master" "${subject}" \
141
144
>>"${SHARED}/deploy-history.tsv"
145
Added:
printf 'HITO_VERSION=%s\n' "${sha:0:12}" >"${SHARED}/deploy.env"
142
146
143
147
chown -R "${DEPLOY_USER}:${DEPLOY_GROUP}" "${rel}"
144
148
chown "${DEPLOY_USER}:${DEPLOY_GROUP}" "${SHARED}/deploy-history.tsv"