From ff171984f4b2141a627cf08ab9e326aa55d87791 Mon Sep 17 00:00:00 2001 From: diamante0018 Date: Fri, 12 Sep 2025 10:06:44 +0200 Subject: [PATCH] feat: build date --- .github/workflows/docker-publish.yml | 3 +++ Dockerfile | 8 ++++++++ aw.py | 7 +++++++ 3 files changed, 18 insertions(+) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index f259bd7..3040559 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -47,3 +47,6 @@ jobs: labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max + build-args: | + BUILD_DATE=${{ github.event.head_commit.timestamp || github.event.repository.pushed_at }} + GIT_TAG=${{ github.ref_name }} diff --git a/Dockerfile b/Dockerfile index 5c4412e..6e883df 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,4 +26,12 @@ ENV DISCOURSE_USERNAME="" # Where the database will be stored ENV BOT_DATA_DIR="" +# Accept build arguments for metadata +ARG BUILD_DATE="" +ARG GIT_TAG="" + +# Set them as environment variables +ENV BUILD_DATE=${BUILD_DATE} +ENV GIT_TAG=${GIT_TAG} + CMD ["/bot-env/bin/python", "aw.py"] diff --git a/aw.py b/aw.py index 7a210cd..f6fd813 100644 --- a/aw.py +++ b/aw.py @@ -19,6 +19,9 @@ bot = commands.Bot(command_prefix="!", intents=intents) # Load environment variables from .env file (if it exists) load_dotenv(os.path.join(os.path.dirname(__file__), ".env")) +build_date = os.getenv("BUILD_DATE") +git_tag = os.getenv("GIT_TAG") + initialize_db() bot.ai_helper = DiscourseSummarizer() @@ -26,6 +29,10 @@ bot.ai_helper = DiscourseSummarizer() @bot.event async def on_ready(): + # Print build info if available + if build_date and git_tag: + logger.info(f"AlterWare Bot - Built on {build_date} {git_tag}") + logger.info(f"{bot.user.name} has connected to Discord!") try: