File tree Expand file tree Collapse file tree 2 files changed +52
-40
lines changed
Expand file tree Collapse file tree 2 files changed +52
-40
lines changed Original file line number Diff line number Diff line change 11# Discord Bots
22
3- ## 開発
3+ ## Bot を追加する
44
5- 特に記述することはなし
5+ ### 1. ` bots/ ` にフォルダを作る
66
7- ## Bot追加方法
7+ ### 2. コードを書く
88
9- 1 .
9+ ### 3. ` run.sh ` を作る
1010
11- ``` sh
12- mkdir bots/YOUR_BOT
11+ ### 4. ` rollcron.yaml ` に追加
12+
13+ ``` yaml
14+ my-bot :
15+ schedule : " 7pm" # 下記参照
16+ working_dir : bots/my-bot
17+ run : ./run.sh
18+ log : ~/run/discord-bots/my-bot/log
19+ # build: ./build.sh # コンパイルが必要な場合
20+ # env_file: ~/run/discord-bots/my-bot/env # 環境変数が必要な場合
21+ ```
22+
23+ schedule の書き方:
24+
25+ ```
26+ "7pm" "8:30am" "noon"
27+ "7pm every Monday" "9am every weekday" "midnight every Friday"
28+ "7am every Sunday" "6pm every 3 days" "noon every 2 weeks"
29+ "0 19 * * *" "30 8 * * 1-5" "0 0 1 * *"
30+ ```
31+
32+ ### 5. ` CODEOWNERS ` に追加
33+
34+ ```
35+ /bots/my-bot/ @your-github-username
1336```
1437
15- 2 . bots/YOUR_BOT にBotを書く
16- 3 . ` rollcron.yaml ` に YOUR_BOT の cron スケジュールとスクリプトを書く。
17- 4 . VPS にすでに実行環境がない場合は、実行環境を作る (Docker ランナーはそのうちサポートする予定)
18- 5 . CODEOWNERS に追加する
38+ ### 6. 環境変数
1939
20- ## デプロイ
40+ 2通りの方法がある:
41+
42+ ```
43+ 1. rollcron.yaml (env_file) → run.sh → program
44+ 2. rollcron.yaml → run.sh → sops → program
45+ ```
2146
22- 環境変数が必要な場合は [ SOPS ] ( docs/sops.md ) で暗号化するか、VPS 上に run/discord-bots/YOUR_BOT/env に書いてください 。
47+ SOPS を使う場合は [ docs/sops.md ] ( docs/sops.md ) を参照 。
Original file line number Diff line number Diff line change 11# SOPS セットアップ
22
3- [ SOPS] ( https://github.com/getsops/sops ) を使って環境変数を暗号化し、Git で安全に管理する。
4-
5- 1 . ` direnv allow ` で開発環境に入る
6- 2 . ` age-keygen -o .age-key ` で自分用のキーを生成(公開鍵が表示される)
7- 3 . ` .sops.yaml ` に公開鍵を追加
8-
9- ``` yaml
10- _ :
11- deploy : &deploy age12n68j7wyf97vrw4jwr5x0gf2zdcumh65r9uq3mctsa6y9f8ex4yqm2gx06
12- your-name : &your-name age1yyy...
13-
14- creation_rules :
15- - path_regex : bots/<your-bot>/.*
16- age :
17- - *deploy
18- - *your-name
19- ```
20-
21- 4 . ` sops bots/<your-bot>/sops.env ` で作成・編集
22- 5 . ` sops.env ` をコミット
3+ 環境変数を暗号化して Git に安全にコミットする。
234
24- ## 復号してコマンド実行
5+ ## 初回セットアップ
256
267``` bash
27- sops exec-env sops.env ' your-command '
28- ```
8+ # 1. 鍵を作成(公開鍵が表示される → コピー)
9+ age-keygen -o .age-key
2910
30- ## 再暗号化
11+ # 2. .sops.yaml に公開鍵を追加してコミット
12+ ```
3113
32- ` .sops.yaml ` のキーを変更した後に実行:
14+ ## 環境変数ファイルを作成
3315
3416``` bash
35- sops updatekeys sops.env
17+ sops bots/my-bot/ sops.env
3618```
3719
38- ## 公開鍵を取得
20+ エディタで環境変数を書いて保存。
21+
22+ ## Bot で使う
23+
24+ ` run.sh ` :
3925
4026``` bash
41- age-keygen -y .age-key
27+ #! /bin/bash
28+ sops exec-env sops.env ' bun run index.ts'
4229```
You can’t perform that action at this time.
0 commit comments