Skip to content

Commit 0c2afd0

Browse files
committed
use rollcron to load env vars
1 parent 624324b commit 0c2afd0

4 files changed

Lines changed: 12 additions & 25 deletions

File tree

bots/asakatsu-bot/run.sh

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

4-
ENV_FILE="${ENV_FILE:-.env}"
54
function bail() {
65
echo "$@"
76
exit 1
87
}
98

10-
# prerequesties
11-
if [ ! -f "$ENV_FILE" ]; then
12-
bail "Prerequesties not met: .env not found"
13-
fi
14-
159
case "$1" in
1610
ask)
1711
bun install --frozen-lockfile
18-
bun --env-file="$ENV_FILE" commands/ask.ts
12+
bun --env-file=.env commands/ask.ts
1913
;;
2014
check)
2115
bun install --frozen-lockfile
22-
bun --env-file="$ENV_FILE" commands/check.ts
16+
bun --env-file=.env commands/check.ts
2317
;;
2418
*)
2519
bail "[asakatsu-bot] Unknown Command: $1"

bots/auto-moderator/run.sh

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
function bail() {
5-
echo "$@"
6-
exit 1
7-
}
8-
9-
ENV_FILE="${ENV_FILE:-.env}"
10-
if [ ! -f "$ENV_FILE" ]; then
11-
bail "Prerequesties not met: .env not found"
12-
fi
13-
144
bun install --frozen-lockfile
15-
bun --env-file="$ENV_FILE" start
5+
bun --env-file=.env start

bots/gsc-report/main.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
const { google } = require("googleapis");
22
const { WebhookClient } = require("discord.js");
33
const dayjs = require("dayjs");
4-
const dotenv = require("dotenv");
5-
dotenv.config({ path: process.env.ENV_FILE });
4+
require("dotenv").config();
65

76
const auth = new google.auth.GoogleAuth({
87
scopes: ["https://www.googleapis.com/auth/webmasters.readonly"],

rollcron.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,26 @@ jobs:
66
schedule:
77
cron: "0 12 * * *"
88
working_dir: bots/auto-moderator
9-
run: ENV_FILE=~/run/discord-bots/auto-moderator.env ./run.sh
9+
run: ./run.sh
10+
env_file: ~/run/discord-bots/auto-moderator.env
1011

1112
gsc-report:
1213
schedule:
1314
cron: "0 0 7 * * 7"
1415
working_dir: bots/gsc-report
15-
run: ENV_FILE=~/run/discord-bots/gsc-report.env ./run.sh
16+
run: ./run.sh
17+
env_file: ~/run/discord-bots/gsc-report.env
1618

1719
asakatsu-bot-ask:
1820
schedule:
1921
cron: "0 19 * * *"
2022
working_dir: bots/asakatsu-bot
21-
run: ENV_FILE=~/run/discord-bots/asakatsu-bot.env ./run.sh ask
23+
run: ./run.sh ask
24+
env_file: ~/run/discord-bots/asakatsu-bot.env
2225

2326
asakatsu-bot-check:
2427
schedule:
2528
cron: "0 8 * * *"
2629
working_dir: bots/asakatsu-bot
27-
run: ENV_FILE=~/run/discord-bots/asakatsu-bot.env ./run.sh check
30+
run: ./run.sh check
31+
env_file: ~/run/discord-bots/asakatsu-bot.env

0 commit comments

Comments
 (0)