From 7dda7f7bb6ee06421d358a8f51cbf455964fb73e Mon Sep 17 00:00:00 2001 From: Derek Roberts Date: Tue, 6 Aug 2024 18:02:11 -0400 Subject: [PATCH] feat(ci): sync build_number envar (#1481) Co-authored-by: ronrobb --- .github/workflows/pr-open.yml | 3 +++ sync/Dockerfile | 4 ++++ sync/src/main.py | 9 +++++++++ 3 files changed, 16 insertions(+) diff --git a/.github/workflows/pr-open.yml b/.github/workflows/pr-open.yml index d6e8bde2b..e72b6ec6e 100644 --- a/.github/workflows/pr-open.yml +++ b/.github/workflows/pr-open.yml @@ -23,6 +23,9 @@ jobs: - uses: bcgov-nr/action-builder-ghcr@v2.2.0 id: build with: + build_args: | + "BUILDKIT_INLINE_CACHE=1" + --build-arg BUILD_NUMBER=${{ github.event.number }} package: ${{ matrix.package }} tag: ${{ github.event.number }} tag_fallback: latest diff --git a/sync/Dockerfile b/sync/Dockerfile index a6e8af047..20fafe169 100644 --- a/sync/Dockerfile +++ b/sync/Dockerfile @@ -1,5 +1,9 @@ FROM python:3.12-slim +# Receive build number as argument, retain as environment variable +ARG BUILD_NUMBER=0 +ENV BUILD_NUMBER=${BUILD_NUMBER} + # Packages and nonroot user RUN apt update && \ apt install -y --no-install-recommends gcc libpq-dev python3-dev && \ diff --git a/sync/src/main.py b/sync/src/main.py index 201ebca8c..7c1148442 100644 --- a/sync/src/main.py +++ b/sync/src/main.py @@ -46,6 +46,9 @@ def generate_db_config(type_,schema_,settings): } return dbconfig +def get_build_number(): + return os.environ.get("BUILD_NUMBER") + def required_variables_exists(): ret = True @@ -110,6 +113,12 @@ def read_settings(): def main() -> None: definition_of_yes = ["Y","YES","1","T","TRUE","t","true"] + + build_number = get_build_number() + print("<------------------ b.u.i.l.d n.u.m.b.e.r ----------------->") + print(f"Running Sync BUILD NUMBER: {build_number}") + print("<------------------ b.u.i.l.d n.u.m.b.e.r ----------------->") + # print(os.environ.get("TEST_MODE")) if os.environ.get("TEST_MODE") is None: print("Error: test mode variable is None")