Commit 0bc3721e authored by Krzysztof Mochocki's avatar Krzysztof Mochocki
Browse files

Refactor acquiring hash of current commit

parent f4d097ae
Pipeline #45743 failed with stages
in 17 seconds
......@@ -52,6 +52,8 @@ ADD --chown=hafah_user:hafah_user ./docker/docker_entrypoint.sh .
USER haf_admin
RUN sudo -n /home/hafah_user/app/docker/docker_build.sh /home/hafah_user ${USE_POSTGREST}
# there is no longer need to waste space for .git/ directory
RUN rm -rf ./app/.git
# JSON rpc service
EXPOSE ${HTTP_PORT}
......
......@@ -5,11 +5,8 @@ set -euo pipefail
ROOT_DIR="${1}"
USE_POSTGREST=${2}
ref_dir=$PWD
chmod a+x $ref_dir/app/scripts/generate_version_sql.bash
pushd /builds/hive/HAfAH
$ref_dir/app/scripts/generate_version_sql.bash $ref_dir/set_version_in_sql.pgsql
popd
chmod a+x $ROOT_DIR/app/scripts/generate_version_sql.bash
$ROOT_DIR/app/scripts/generate_version_sql.bash $ROOT_DIR/app
chmod a+x ${ROOT_DIR}/docker_entrypoint.sh
cd ${ROOT_DIR}/app
......
#! /bin/bash
# usage: ./generate_version_sql.bash root_project_dir
set -euo pipefail
GIT_HASH=`$CI_GIT_PRIVILLAGES git rev-parse HEAD`
# acquiring hash without git
GIT_HASH=`cat "$1/.git/$(cat $1/.git/HEAD | cut -d ' ' -f 2)"`
echo "
CREATE SCHEMA IF NOT EXISTS hafah_private;
......@@ -13,4 +16,4 @@ CREATE TABLE hafah_private.version(
);
INSERT INTO hafah_private.version VALUES($GIT_HASH);
" > $1
" > $1/set_version_in_sql.pgsql
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment