Skip to content

Commit 793993f

Browse files
committed
bots/asakatsu-bot: use plaintext env file for secret management
1 parent 380b9bb commit 793993f

4 files changed

Lines changed: 15 additions & 6 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ node_modules
44
.devenv
55
.env
66
.envrc.local
7+
8+
.sops-key-file

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Discord Bots
22

3-
何か書く。
3+
## 開発
4+
5+
特に記述することはなし
46

57
## Bot追加方法
68

@@ -13,3 +15,7 @@ mkdir bots/YOUR_BOT
1315
2. bots/YOUR_BOT にBotを書く
1416
3. `rollcron.yaml` に YOUR_BOT の cron スケジュールとスクリプトを書く。
1517
4. VPS にすでに実行環境がない場合は、実行環境を作る (Docker ランナーはそのうちサポートする予定)
18+
19+
## デプロイ
20+
21+
環境変数が必要な場合は VPS 上に variables/discord-bots/YOUR_BOT.env を用意してください。そのうち SOPS を導入するかもしれないし、しないかもしれない

bots/asakatsu-bot/run.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4+
ENV_FILE="${ENV_FILE:-.env}"
45
function bail() {
56
echo "$@"
67
exit 1
78
}
89

910
# prerequesties
10-
if [ ! -f .env ]; then
11+
if [ ! -f "$ENV_FILE" ]; then
1112
bail "Prerequesties not met: .env not found"
1213
fi
1314

1415
case "$1" in
1516
ask)
1617
bun install --frozen-lockfile
17-
bun --env-file=.env commands/ask.ts
18+
bun --env-file="$ENV_FILE" commands/ask.ts
1819
;;
1920
check)
2021
bun install --frozen-lockfile
21-
bun --env-file=.env commands/check.ts
22+
bun --env-file="$ENV_FILE" commands/check.ts
2223
;;
2324
*)
2425
bail "[asakatsu-bot] Unknown Command: $1"

rollcron.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ jobs:
1616
asakatsu-bot-ask:
1717
schedule:
1818
cron: "0 19 * * *"
19-
run: run.sh ask
19+
run: ENV_FILE=~/variables/discord-bots/asakatsu-bot.env run.sh ask
2020
asakatsu-bot-check:
2121
schedule:
2222
cron: "0 8 * * *"
23-
run: run.sh check
23+
run: ENV_FILE=~/variables/discord-bots/asakatsu-bot.env run.sh check

0 commit comments

Comments
 (0)