Move generation of build info to script

This commit is contained in:
Carlos Quintana 2022-05-12 16:48:51 +02:00
parent d6a50ff864
commit 0ed45f54c6
No known key found for this signature in database
GPG Key ID: 15E73DCC410679F8
2 changed files with 22 additions and 5 deletions

View File

@ -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

15
scripts/generate-build-info.sh Executable file
View File

@ -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