From 4cb7666826bc0c3960d8bf5912634b227c13d72b Mon Sep 17 00:00:00 2001 From: imnyang Date: Thu, 11 Dec 2025 01:19:09 +0900 Subject: [PATCH] Update Dockerfile, main.yml, and index.ts for bot configuration and activity status --- .github/workflows/main.yml | 4 ++-- Dockerfile | 6 +++--- compose.yml | 12 ++++++++++++ src/index.ts | 19 ++++++++++++++++++- 4 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 compose.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 92dc719..940e3b1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,8 +40,8 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max tags: | - ghcr.io/imnyang/yanmang/bot:latest - ghcr.io/imnyang/yanmang/bot:${{ env.RELEASE_VERSION }} + ghcr.io/imnyang/memos-rss/bot:latest + ghcr.io/imnyang/memos-rss/bot:${{ env.RELEASE_VERSION }} - name: Create GitHub Release if: startsWith(github.ref, 'refs/tags/') diff --git a/Dockerfile b/Dockerfile index d69f0c3..3776838 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,6 @@ FROM oven/bun:alpine as build -# Set timezone to KST -ENV TZ=Asia/Seoul -RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone +RUN apk add --no-cache tzdata git WORKDIR /app @@ -20,6 +18,8 @@ RUN bun run build FROM alpine:latest as runtime +RUN apk add --no-cache tzdata + ENV TZ=Asia/Seoul RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone diff --git a/compose.yml b/compose.yml new file mode 100644 index 0000000..d67e9f6 --- /dev/null +++ b/compose.yml @@ -0,0 +1,12 @@ +services: + # Main Discord bot application + bot: + image: ghcr.io/imnyang/memos-rss/bot:latest + container_name: bot + restart: unless-stopped + env_file: + - .env + volumes: + # Mount any persistent data directories if needed + - ./rss.toml:/app/rss.toml + - ./processed.json:/app/processed.json \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index aa9fc82..3f2da02 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -import { Client, GatewayIntentBits, REST, Routes } from "discord.js"; +import { ActivityType, Client, GatewayIntentBits, REST, Routes } from "discord.js"; import { token, INTERVAL_MS } from "./lib/config"; import { commands, handleClearForum } from "./commands"; import { checkRssFeeds } from "./lib/rss"; @@ -7,8 +7,25 @@ const client = new Client({ intents: [GatewayIntentBits.Guilds], }); +async function getGitCommitHash(): Promise { + try { + const data = await Bun.file("./version").text(); + return data.trim(); + } catch { + return "unknown"; + } +} + client.once("clientReady", async () => { console.log(`Logged in as: ${client.user?.tag}`); + + // Git commit hash로 상태 설정 + const commitHash = await getGitCommitHash(); + client.user?.setActivity({ + name: `${commitHash}`, + type: ActivityType.Playing, + }); + console.log(`Version: ${commitHash}`); // Register slash commands try {