feat: build date

This commit is contained in:
2025-09-12 10:06:44 +02:00
parent 6f3bc7080b
commit ff171984f4
3 changed files with 18 additions and 0 deletions

View File

@@ -47,3 +47,6 @@ jobs:
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha cache-from: type=gha
cache-to: type=gha,mode=max 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 }}

View File

@@ -26,4 +26,12 @@ ENV DISCOURSE_USERNAME=""
# Where the database will be stored # Where the database will be stored
ENV BOT_DATA_DIR="" 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"] CMD ["/bot-env/bin/python", "aw.py"]

7
aw.py
View File

@@ -19,6 +19,9 @@ bot = commands.Bot(command_prefix="!", intents=intents)
# Load environment variables from .env file (if it exists) # Load environment variables from .env file (if it exists)
load_dotenv(os.path.join(os.path.dirname(__file__), ".env")) load_dotenv(os.path.join(os.path.dirname(__file__), ".env"))
build_date = os.getenv("BUILD_DATE")
git_tag = os.getenv("GIT_TAG")
initialize_db() initialize_db()
bot.ai_helper = DiscourseSummarizer() bot.ai_helper = DiscourseSummarizer()
@@ -26,6 +29,10 @@ bot.ai_helper = DiscourseSummarizer()
@bot.event @bot.event
async def on_ready(): 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!") logger.info(f"{bot.user.name} has connected to Discord!")
try: try: