Skip to content

Commit 3b48611

Browse files
author
timhauke
committed
chore: added docker files and some workflows for better automation.
1 parent 36e3c3e commit 3b48611

File tree

11 files changed

+315
-51
lines changed

11 files changed

+315
-51
lines changed

.dockerignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.git
2+
.github
3+
.venv
4+
.mypy_cache
5+
__pycache__
6+
*.pyc
7+
.env
8+
.env.local
9+
.env.*.backup
10+
docs/
11+
tests/
12+
node_modules/
13+
*.log

.env.example

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copy this file to `.env` and populate the secrets before running the bot
2+
3+
# Discord bot token (https://discord.com/developers/applications)
4+
DISCORD_TOKEN=YOUR_DISCORD_BOT_TOKEN
5+
6+
# Lavalink connection overrides (optional if values already exist in config.yml)
7+
LAVALINK_HOST=lavalink.example.com
8+
LAVALINK_PORT=2333
9+
LAVALINK_PASSWORD=supersecret
10+
LAVALINK_HTTPS=false
11+
LAVALINK_NAME=main
12+
LAVALINK_REGION=eu
13+
14+
# Optional: specify an alternate configuration file
15+
# CONFIG_PATH=config.yml

.github/release-drafter.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name-template: "v$NEXT_PATCH_VERSION"
2+
tag-template: "v$NEXT_PATCH_VERSION"
3+
categories:
4+
- title: "🚀 Features"
5+
labels:
6+
- feature
7+
- enhancement
8+
- title: "🐛 Fixes"
9+
labels:
10+
- bug
11+
- fix
12+
- bugfix
13+
- title: "🛠 Maintenance"
14+
labels:
15+
- chore
16+
- maintenance
17+
- refactor
18+
- title: "📖 Documentation"
19+
labels:
20+
- docs
21+
- documentation
22+
- title: "🧪 Testing"
23+
labels:
24+
- test
25+
- tests
26+
change-template: "- $TITLE (#$NUMBER) @$AUTHOR"
27+
no-changes-template: "No changes in this release."
28+
template: |
29+
## What's Changed
30+
31+
$CHANGES
32+
33+
## Contributors
34+
35+
$CONTRIBUTORS

.github/workflows/build.yml

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,36 @@
1-
name: 🏗️ Build
1+
name: 🏗️ Build Container
22

33
on:
44
push:
5-
branches: [main]
5+
branches:
6+
- main
7+
- develop
8+
pull_request:
9+
branches:
10+
- main
11+
- develop
612
workflow_dispatch:
713

814
jobs:
915
build:
1016
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
1119
steps:
12-
- uses: actions/checkout@v4
13-
- name: Setup Python
14-
uses: actions/setup-python@v5
15-
with:
16-
python-version: "3.11"
17-
- name: Install dependencies
18-
run: |
19-
python -m pip install --upgrade pip
20-
pip install -r requirements.txt
21-
- name: Build package
22-
run: |
23-
mkdir -p dist
24-
zip -r dist/vectobeat.zip src config.yml requirements.txt .env
25-
- name: Upload Artifact
26-
uses: actions/upload-artifact@v4
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v3
25+
26+
- name: Build container image
27+
uses: docker/build-push-action@v5
2728
with:
28-
name: vectobeat-build
29-
path: dist/vectobeat.zip
29+
context: .
30+
file: Dockerfile
31+
push: false
32+
load: true
33+
tags: vectobeat:ci
34+
35+
- name: Smoke test container
36+
run: docker run --rm vectobeat:ci python -m compileall src

.github/workflows/deploy.yml

Lines changed: 70 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,82 @@
1-
name: 🚀 Deploy VectoBeat
1+
name: 🚀 Release & Publish
22

33
on:
44
release:
55
types: [published]
66
workflow_dispatch:
77

8+
env:
9+
REGISTRY: ghcr.io
10+
IMAGE_NAME: ${{ github.repository }}
11+
12+
permissions:
13+
contents: read
14+
packages: write
15+
816
jobs:
17+
publish-image:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Extract metadata (tags, labels)
24+
id: meta
25+
uses: docker/metadata-action@v5
26+
with:
27+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
28+
tags: |
29+
type=ref,event=release
30+
type=ref,event=tag
31+
type=raw,value=latest
32+
33+
- name: Set up Docker Buildx
34+
uses: docker/setup-buildx-action@v3
35+
36+
- name: Log in to GitHub Container Registry
37+
uses: docker/login-action@v3
38+
with:
39+
registry: ${{ env.REGISTRY }}
40+
username: ${{ github.actor }}
41+
password: ${{ secrets.GITHUB_TOKEN }}
42+
43+
- name: Build and push image
44+
uses: docker/build-push-action@v5
45+
with:
46+
context: .
47+
file: Dockerfile
48+
push: true
49+
tags: ${{ steps.meta.outputs.tags }}
50+
labels: ${{ steps.meta.outputs.labels }}
51+
952
deploy:
53+
needs: publish-image
1054
runs-on: ubuntu-latest
55+
if: ${{ secrets.DEPLOY_SSH_HOST != '' && secrets.DEPLOY_SSH_USER != '' && secrets.DEPLOY_SSH_KEY != '' && secrets.DEPLOY_TARGET_PATH != '' }}
1156
steps:
12-
- uses: actions/checkout@v4
57+
- name: Sync container to server
58+
uses: appleboy/scp-action@v0.1.7
59+
with:
60+
host: ${{ secrets.DEPLOY_SSH_HOST }}
61+
username: ${{ secrets.DEPLOY_SSH_USER }}
62+
key: ${{ secrets.DEPLOY_SSH_KEY }}
63+
source: docker-compose.yml
64+
target: ${{ secrets.DEPLOY_TARGET_PATH }}
1365

14-
- name: Setup Python
15-
uses: actions/setup-python@v5
66+
- name: Trigger remote deployment
67+
uses: appleboy/ssh-action@v1.0.3
1668
with:
17-
python-version: "3.11"
18-
19-
- name: Install dependencies
20-
run: |
21-
python -m pip install --upgrade pip
22-
pip install -r requirements.txt
23-
24-
- name: Deploy to Production
25-
env:
26-
DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
27-
LAVALINK_HOST: ${{ secrets.LAVALINK_HOST }}
28-
LAVALINK_PORT: ${{ secrets.LAVALINK_PORT }}
29-
LAVALINK_PASSWORD: ${{ secrets.LAVALINK_PASSWORD }}
30-
run: |
31-
echo "🚀 Deploying VectoBeat..."
32-
python -m src.main
69+
host: ${{ secrets.DEPLOY_SSH_HOST }}
70+
username: ${{ secrets.DEPLOY_SSH_USER }}
71+
key: ${{ secrets.DEPLOY_SSH_KEY }}
72+
envs: REGISTRY,IMAGE_NAME,GITHUB_ACTOR,GITHUB_TOKEN
73+
env:
74+
REGISTRY: ${{ env.REGISTRY }}
75+
IMAGE_NAME: ${{ env.IMAGE_NAME }}
76+
GITHUB_ACTOR: ${{ github.actor }}
77+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78+
script: |
79+
docker login $REGISTRY -u "$GITHUB_ACTOR" -p "$GITHUB_TOKEN"
80+
cd ${{ secrets.DEPLOY_TARGET_PATH }}
81+
docker compose pull
82+
docker compose up -d --remove-orphans

.github/workflows/docs.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: 📚 Documentation Guard
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "README.md"
7+
- "docs/**"
8+
- "assets/images/**"
9+
push:
10+
branches:
11+
- main
12+
paths:
13+
- "README.md"
14+
- "docs/**"
15+
- "assets/images/**"
16+
workflow_dispatch:
17+
18+
jobs:
19+
mermaid-diagram:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: "18"
29+
30+
- name: Install Mermaid CLI
31+
run: npm install -g @mermaid-js/mermaid-cli
32+
33+
- name: Regenerate architecture diagram
34+
run: mmdc -i docs/system_architecture.mmd -o assets/images/architecture.png -t dark
35+
36+
- name: Ensure diagram is committed
37+
run: git diff --exit-code assets/images/architecture.png
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: 📝 Release Drafter
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
update-draft:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Run Release Drafter
17+
uses: release-drafter/release-drafter@v6
18+
with:
19+
config-name: release-drafter.yml

.github/workflows/security.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: 🔐 Dependency Audit
2+
3+
on:
4+
schedule:
5+
- cron: "0 3 * * 1" # Every Monday at 03:00 UTC
6+
workflow_dispatch:
7+
push:
8+
paths:
9+
- requirements.txt
10+
- ".github/workflows/security.yml"
11+
12+
jobs:
13+
pip-audit:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: "3.11"
23+
cache: "pip"
24+
cache-dependency-path: requirements.txt
25+
26+
- name: Install audit tooling
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install pip-audit
30+
31+
- name: Run pip-audit
32+
run: pip-audit -r requirements.txt --format cyclonedx-json --output pip-audit.json
33+
34+
- name: Upload audit report
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: pip-audit-report
38+
path: pip-audit.json

.github/workflows/test.yml

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
name: 🧪 Tests
1+
name: 🛡️ Quality Gate
22

33
on:
44
push:
5-
branches: [main, develop]
5+
branches:
6+
- main
7+
- develop
68
pull_request:
7-
branches: [main, develop]
9+
branches:
10+
- main
11+
- develop
812

913
jobs:
1014
test:
@@ -13,20 +17,30 @@ jobs:
1317
matrix:
1418
python-version: ["3.10", "3.11"]
1519
steps:
16-
- uses: actions/checkout@v4
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
1723
- name: Setup Python
1824
uses: actions/setup-python@v5
1925
with:
2026
python-version: ${{ matrix.python-version }}
27+
cache: "pip"
28+
cache-dependency-path: |
29+
requirements.txt
30+
2131
- name: Install dependencies
2232
run: |
2333
python -m pip install --upgrade pip
2434
pip install -r requirements.txt
25-
- name: Lint
26-
run: |
27-
pip install flake8
28-
flake8 src --max-line-length=120
29-
- name: Run tests
30-
run: |
31-
pip install pytest
32-
pytest -v
35+
pip install flake8 pytest
36+
37+
- name: Lint (flake8)
38+
if: matrix.python-version == '3.11'
39+
run: flake8 src --max-line-length=120
40+
41+
- name: Byte-compile sources
42+
if: matrix.python-version == '3.11'
43+
run: python -m compileall src
44+
45+
- name: Run pytest
46+
run: pytest -q

0 commit comments

Comments
 (0)