Skip to content

Commit 3501e01

Browse files
committed
Merge branch 'master' into commands-fix
2 parents 364ba7e + dc25641 commit 3501e01

18 files changed

Lines changed: 216 additions & 170 deletions

File tree

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ shell.nix
1919
config.json
2020
*.config.json
2121
.npmrc
22+
data/
23+
docs/
24+
lefthook.yml

.github/workflows/CD.yaml

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,30 @@ jobs:
2323
BOT_HOME_DIR: /home/csc
2424

2525
steps:
26-
- uses: actions/checkout@v6
27-
with:
28-
show-progress: false
29-
30-
- name: Copy infra directory
31-
uses: appleboy/scp-action@v1.0.0
32-
with:
33-
host: ${{ secrets.SSH_HOST }}
34-
username: ${{ secrets.SSH_USERNAME }}
35-
key: ${{ secrets.SSH_KEY }}
36-
port: ${{ secrets.SSH_PORT }}
37-
source: .infra
38-
target: ${{ env.BOT_HOME_DIR }}
39-
overwrite: true
40-
41-
42-
- name: Deploy CSZ Bot
43-
uses: appleboy/ssh-action@823bd89e131d8d508129f9443cad5855e9ba96f0
44-
env:
45-
BOT_HOME_DIR: ${{ env.BOT_HOME_DIR }}
46-
with:
47-
host: ${{ secrets.SSH_HOST }}
48-
username: ${{ secrets.SSH_USERNAME }}
49-
key: ${{ secrets.SSH_KEY }}
50-
port: ${{ secrets.SSH_PORT }}
51-
envs: BOT_HOME_DIR
52-
script: ${{ env.BOT_HOME_DIR }}/.infra/deploy.sh
26+
- uses: actions/checkout@v6
27+
with:
28+
show-progress: false
29+
30+
- name: Copy infra directory
31+
uses: appleboy/scp-action@v1.0.0
32+
with:
33+
host: ${{ secrets.SSH_HOST }}
34+
username: ${{ secrets.SSH_USERNAME }}
35+
key: ${{ secrets.SSH_KEY }}
36+
port: ${{ secrets.SSH_PORT }}
37+
source: .infra
38+
target: ${{ env.BOT_HOME_DIR }}
39+
overwrite: true
40+
41+
42+
- name: Deploy CSZ Bot
43+
uses: appleboy/ssh-action@0ff4204d59e8e51228ff73bce53f80d53301dee2
44+
env:
45+
BOT_HOME_DIR: ${{ env.BOT_HOME_DIR }}
46+
with:
47+
host: ${{ secrets.SSH_HOST }}
48+
username: ${{ secrets.SSH_USERNAME }}
49+
key: ${{ secrets.SSH_KEY }}
50+
port: ${{ secrets.SSH_PORT }}
51+
envs: BOT_HOME_DIR
52+
script: ${{ env.BOT_HOME_DIR }}/.infra/deploy.sh

.github/workflows/CI.yaml

Lines changed: 119 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,21 @@ jobs:
2626
pull-requests: write
2727

2828
steps:
29-
- uses: actions/checkout@v6
30-
with:
31-
show-progress: false
32-
fetch-depth: 0
33-
34-
- uses: actions/setup-node@v6
35-
with:
36-
node-version: 24.x
37-
cache: npm
38-
39-
- run: npm ci
40-
env:
41-
YOUTUBE_DL_SKIP_DOWNLOAD: true
42-
- run: npm run ci
43-
- run: npm test
29+
- uses: actions/checkout@v6
30+
with:
31+
show-progress: false
32+
fetch-depth: 0
33+
34+
- uses: actions/setup-node@v6
35+
with:
36+
node-version: 24.x
37+
cache: npm
38+
39+
- run: npm ci
40+
env:
41+
YOUTUBE_DL_SKIP_DOWNLOAD: true
42+
- run: npm run ci
43+
- run: npm test
4444

4545
build:
4646
name: Build
@@ -57,55 +57,57 @@ jobs:
5757
image-digest: ${{ steps.build.outputs.digest }}
5858

5959
steps:
60-
- uses: actions/checkout@v6
61-
with:
62-
show-progress: false
63-
64-
- uses: docker/setup-qemu-action@v3
65-
- uses: docker/setup-buildx-action@v3
66-
- uses: docker/login-action@v3
67-
with:
68-
registry: "ghcr.io"
69-
username: ${{ github.actor }}
70-
password: ${{ secrets.GITHUB_TOKEN }}
71-
72-
- name: Docker meta
73-
id: meta
74-
uses: docker/metadata-action@v5
75-
with:
76-
images: |
77-
ghcr.io/nulldev/csz-bot
78-
tags: |
79-
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }}
80-
type=ref,event=branch
81-
type=ref,event=pr
82-
type=semver,pattern={{version}}
83-
type=semver,pattern={{major}}.{{minor}}
84-
85-
- name: Extract tag
86-
id: tag
87-
env:
88-
INPUT_TAGS: ${{ steps.meta.outputs.tags }}
89-
run: |
90-
first=$(echo "$INPUT_TAGS" | head -n 1)
91-
92-
echo "first=$first" >> "$GITHUB_OUTPUT"
93-
94-
95-
- name: Build and export
96-
uses: docker/build-push-action@v6
97-
id: build
98-
with:
99-
push: ${{ !github.event.repository.fork }}
100-
pull: true
101-
tags: ${{ steps.meta.outputs.tags }}
102-
labels: ${{ steps.meta.outputs.labels }}
103-
build-args: |
104-
RELEASE_IDENTIFIER=${{ github.sha }}
105-
BUILD_NUMBER=${{ github.run_number }}
106-
load: true
107-
cache-from: type=gha
108-
cache-to: type=gha,mode=max
60+
- uses: actions/checkout@v6
61+
with:
62+
show-progress: false
63+
64+
- uses: docker/setup-qemu-action@v3
65+
- uses: docker/setup-buildx-action@v3
66+
- uses: docker/login-action@v3
67+
with:
68+
registry: "ghcr.io"
69+
username: ${{ github.actor }}
70+
password: ${{ secrets.GITHUB_TOKEN }}
71+
72+
- name: Docker meta
73+
id: meta
74+
uses: docker/metadata-action@v5
75+
with:
76+
images: |
77+
ghcr.io/nulldev/csz-bot
78+
tags: |
79+
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }}
80+
type=ref,event=branch
81+
type=ref,event=pr
82+
type=semver,pattern={{version}}
83+
type=semver,pattern={{major}}.{{minor}}
84+
85+
- name: Extract tag
86+
id: tag
87+
env:
88+
INPUT_TAGS: ${{ steps.meta.outputs.tags }}
89+
run: |
90+
first=$(echo "$INPUT_TAGS" | head -n 1)
91+
92+
echo "first=$first" >> "$GITHUB_OUTPUT"
93+
94+
95+
- name: Build and export
96+
uses: docker/build-push-action@v6
97+
id: build
98+
with:
99+
# context needed, so we use path context instead of git context, so .dockerignore is respected
100+
context: "."
101+
push: ${{ !github.event.repository.fork }}
102+
pull: true
103+
tags: ${{ steps.meta.outputs.tags }}
104+
labels: ${{ steps.meta.outputs.labels }}
105+
build-args: |
106+
RELEASE_IDENTIFIER=${{ github.sha }}
107+
BUILD_NUMBER=${{ github.run_number }}
108+
load: true
109+
cache-from: type=gha
110+
cache-to: type=gha,mode=max
109111

110112
deploy-e2e:
111113
name: Deploy e2e
@@ -120,56 +122,56 @@ jobs:
120122
name: e2e
121123

122124
steps:
123-
- uses: actions/checkout@v6
124-
with:
125-
show-progress: false
126-
127-
- name: Update configuration
128-
env:
129-
DISCORD_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
130-
DISCORD_CLIENT_ID: ${{ secrets.CI_CLIENT_ID }}
131-
PR_ID: ${{ github.event.number }}
132-
run: |
133-
envsubst < .github/config.json > config.json
134-
135-
- name: Read config.json
136-
id: config
137-
uses: juliangruber/read-file-action@v1
138-
with:
139-
path: ./config.json
140-
141-
- name: Build args
142-
id: args
143-
env:
144-
DRY_RUN: ${{ github.ref == 'refs/heads/master' }}
145-
run: |
146-
args=""
147-
148-
if [[ $DRY_RUN = true ]]; then
149-
args="--dry-run"
150-
fi
151-
152-
echo "args=$args" >> "$GITHUB_OUTPUT"
153-
154-
- name: Deploy CSZ Bot
155-
uses: appleboy/ssh-action@823bd89e131d8d508129f9443cad5855e9ba96f0
156-
env:
157-
BOT_HOME_PATH: /home/csc
158-
EPHEMERAL_BOT_CONFIG: ${{ steps.config.outputs.content }}
159-
BOT_ARGS: ${{ steps.args.outputs.args }}
160-
BOT_IMAGE: ${{ needs.build.outputs.image-tag }}
161-
with:
162-
host: ${{ secrets.SSH_HOST }}
163-
username: ${{ secrets.SSH_USERNAME }}
164-
key: ${{ secrets.SSH_KEY }}
165-
port: ${{ secrets.SSH_PORT }}
166-
envs: BOT_HOME_PATH,EPHEMERAL_BOT_CONFIG,BOT_ARGS,BOT_IMAGE
167-
script: ${{ env.BOT_HOME_PATH }}/.infra/deploy-ephemeral.sh
168-
169-
- name: Comment PR
170-
uses: thollander/actions-comment-pull-request@v3
171-
if: ${{ github.event_name == 'pull_request' }}
172-
with:
173-
comment-tag: discord-invite
174-
message: |
175-
Hallo, hier kannst du jetzt deine tolle neue Funktion testen: https://discord.gg/pJjfF6n2ec
125+
- uses: actions/checkout@v6
126+
with:
127+
show-progress: false
128+
129+
- name: Update configuration
130+
env:
131+
DISCORD_TOKEN: ${{ secrets.CI_BOT_TOKEN }}
132+
DISCORD_CLIENT_ID: ${{ secrets.CI_CLIENT_ID }}
133+
PR_ID: ${{ github.event.number }}
134+
run: |
135+
envsubst < .github/config.json > config.json
136+
137+
- name: Read config.json
138+
id: config
139+
uses: juliangruber/read-file-action@v1
140+
with:
141+
path: ./config.json
142+
143+
- name: Build args
144+
id: args
145+
env:
146+
DRY_RUN: ${{ github.ref == 'refs/heads/master' }}
147+
run: |
148+
args=""
149+
150+
if [[ $DRY_RUN = true ]]; then
151+
args="--dry-run"
152+
fi
153+
154+
echo "args=$args" >> "$GITHUB_OUTPUT"
155+
156+
- name: Deploy CSZ Bot
157+
uses: appleboy/ssh-action@0ff4204d59e8e51228ff73bce53f80d53301dee2
158+
env:
159+
BOT_HOME_PATH: /home/csc
160+
EPHEMERAL_BOT_CONFIG: ${{ steps.config.outputs.content }}
161+
BOT_ARGS: ${{ steps.args.outputs.args }}
162+
BOT_IMAGE: ${{ needs.build.outputs.image-tag }}
163+
with:
164+
host: ${{ secrets.SSH_HOST }}
165+
username: ${{ secrets.SSH_USERNAME }}
166+
key: ${{ secrets.SSH_KEY }}
167+
port: ${{ secrets.SSH_PORT }}
168+
envs: BOT_HOME_PATH,EPHEMERAL_BOT_CONFIG,BOT_ARGS,BOT_IMAGE
169+
script: ${{ env.BOT_HOME_PATH }}/.infra/deploy-ephemeral.sh
170+
171+
- name: Comment PR
172+
uses: thollander/actions-comment-pull-request@v3
173+
if: ${{ github.event_name == 'pull_request' }}
174+
with:
175+
comment-tag: discord-invite
176+
message: |
177+
Hallo, hier kannst du jetzt deine tolle neue Funktion testen: https://discord.gg/pJjfF6n2ec

.gitignore

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,16 @@ config.json
88
# Dependency directories
99
node_modules/
1010

11-
# TypeScript cache
12-
*.tsbuildinfo
13-
14-
# Optional npm cache directory
15-
.npm
16-
1711
# Output of 'npm pack'
1812
*.tgz
1913

2014
.env
2115
.env.*
2216
!.env.*.example
2317

24-
dist
2518
.cache/
2619

2720
*.db
2821
.idea/
29-
built/
22+
23+
data/

.infra/backup-db.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ mkdir -p backups
66
TARGET_FILE=backups/$TODAY-backup.db
77

88
sqlite3 storage.db ".backup $TARGET_FILE"
9-
xz "$TARGET_FILE"
9+
zstd -19 --rm "$TARGET_FILE"

.infra/compose.yaml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,8 @@ services:
44
restart: unless-stopped
55
image: ghcr.io/nulldev/csz-bot:latest
66
environment:
7-
- LOG_LEVEL=debug
7+
LOG_LEVEL: debug
8+
DATABASE_PATH: /app/data/storage.db
89
volumes:
9-
# cannot use docker secrets because the file will be updated by yt-dlp
10-
- ../cookies-youtube.txt:/cookies-youtube.txt
1110
- ../config.json:/app/config.json:ro
12-
- ../sounds:/app/sounds:ro
13-
- ../banners:/app/banners:ro
14-
- ../storage.db:/app/storage.db
15-
- ../logs:/app/logs
16-
- /etc/timezone:/etc/timezone:ro
17-
- /etc/localtime:/etc/localtime:ro
11+
- ../data:/app/data

.infra/deploy-ephemeral.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ fi
1414
TEMP_DIR=$(mktemp -d)
1515
cd "$TEMP_DIR"
1616

17-
cp -r "$BOT_HOME_PATH/banners" "$TEMP_DIR"
18-
cp -r "$BOT_HOME_PATH/sounds" "$TEMP_DIR"
19-
cp -r "$BOT_HOME_PATH/.infra" "$TEMP_DIR"
17+
mkdir -p "$TEMP_DIR/data"
18+
19+
cp -r "$BOT_HOME_PATH/data" "$TEMP_DIR/data"
20+
cp -r "$BOT_HOME_PATH/.infra" "$TEMP_DIR/.infra"
2021

2122
echo "$EPHEMERAL_BOT_CONFIG" > config.json
2223
echo "" >.env # Dummy env

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ FROM node:alpine
2222
apk add --no-cache \
2323
font-noto-emoji \
2424
fontconfig \
25-
ffmpeg \
2625
font-liberation \
2726
python3 \
27+
ffmpeg \
2828
py-pip \
2929
&& fc-cache -f -v \
3030
&& pip install "yt-dlp[default]" --break-system-packages

assets/banners/1.png

472 KB
Loading

assets/banners/2.gif

5.66 MB
Loading

0 commit comments

Comments
 (0)