Merge pull request #980 from simple-login/ci/generate-build-info-on-script

Move generation of build info to script
This commit is contained in:
Adrià Casajús 2022-05-12 16:54:27 +02:00 committed by GitHub
commit 6880fe2150
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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