- Proper modular structure: src/commands/ + src/lib/ - Autocomplete for /logs and /restart (live container names) - All metrics queries run in parallel (Promise.all) - Multi-stage Docker build (builder + production) - TypeScript type check as CI job before docker build Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
58 lines
2 KiB
YAML
58 lines
2 KiB
YAML
name: CI/CD
|
|
|
|
on:
|
|
push:
|
|
branches: [master]
|
|
pull_request:
|
|
branches: [master]
|
|
|
|
jobs:
|
|
# ── Type check ───────────────────────────────────────────────────────────────
|
|
typecheck:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
cache: npm
|
|
|
|
- run: npm ci
|
|
- run: npm run build
|
|
|
|
# ── Build & push Docker image ─────────────────────────────────────────────
|
|
docker:
|
|
needs: typecheck
|
|
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Login to Forgejo Container Registry
|
|
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login git.csrx.ru -u ${{ github.actor }} --password-stdin
|
|
|
|
- name: Build & push
|
|
run: |
|
|
docker build -t git.csrx.ru/jack/discord-bot:latest .
|
|
docker push git.csrx.ru/jack/discord-bot:latest
|
|
|
|
# ── Deploy to server ───────────────────────────────────────────────────────
|
|
deploy:
|
|
needs: docker
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Configure SSH
|
|
run: |
|
|
mkdir -p ~/.ssh
|
|
printf '%s\n' "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
|
|
chmod 600 ~/.ssh/id_ed25519
|
|
ssh-keyscan -p 22 87.249.49.32 >> ~/.ssh/known_hosts
|
|
chmod 600 ~/.ssh/known_hosts
|
|
|
|
- name: Pull & restart
|
|
run: |
|
|
ssh deploy@87.249.49.32 "
|
|
docker pull git.csrx.ru/jack/discord-bot:latest &&
|
|
docker compose -f /opt/services/docker-compose.yml up -d --no-deps discord-bot
|
|
"
|