mirror of
https://github.com/alterware/aw-bot.git
synced 2025-11-18 00:52:09 +00:00
feat: build date
This commit is contained in:
3
.github/workflows/docker-publish.yml
vendored
3
.github/workflows/docker-publish.yml
vendored
@@ -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 }}
|
||||||
|
|||||||
@@ -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
7
aw.py
@@ -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:
|
||||||
|
|||||||
Reference in New Issue
Block a user