diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index de09a763..ae0dae9c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -84,6 +84,11 @@ jobs: run: | CONFIG=tests/test.env poetry run alembic upgrade head + - name: Prepare version file + run: | + scripts/generate-build-info.sh ${{ github.ref }} + cat app/build_info.py + - name: Test with pytest run: | poetry run pytest @@ -120,11 +125,8 @@ jobs: - name: Prepare version file run: | - BUILD_INFO_FILE=app/build_info.py - echo "SHA1 = '${{ github.ref }}'" > $BUILD_INFO_FILE - BUILD_TIME=$(date +%s) - echo "BUILD_TIME = '${BUILD_TIME}' >> $BUILD_INFO_FILE - cat $BUILD_INFO_FILE + scripts/generate-build-info.sh ${{ github.ref }} + cat app/build_info.py - name: Build image and publish to Docker Registry uses: docker/build-push-action@v3 diff --git a/scripts/generate-build-info.sh b/scripts/generate-build-info.sh new file mode 100755 index 00000000..000b4f4c --- /dev/null +++ b/scripts/generate-build-info.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +SCRIPT_DIR="$(cd "$(dirname "$0")" || exit 1; pwd -P)" +REPO_ROOT=$(echo "${SCRIPT_DIR}" | sed 's:scripts::g') +BUILD_INFO_FILE="${REPO_ROOT}/app/build_info.py" + +if [[ -z "$1" ]]; then + echo "This script needs to be invoked with the version as an argument" + exit 1 +fi + +VERSION="$1" +echo "SHA1 = \"${VERSION}\"" > $BUILD_INFO_FILE +BUILD_TIME=$(date +%s) +echo "BUILD_TIME = \"${BUILD_TIME}\"" >> $BUILD_INFO_FILE