mirror of
https://github.com/dsec-hub/dsec-discord-bot.git
synced 2026-09-22 07:44:26 +00:00
- docker-compose.yml: `restart: unless-stopped` so a panic, bad frame or VPS reboot brings the bot back instead of leaving it dead. Comment explaining why no healthcheck (slim runtime, no HTTP port). - Cargo.toml: enable tracing-subscriber's env-filter feature (declared but never initialised until now). - main.rs: initialise tracing as the first statement in main(), defaulting to `info` — serenity/poise/supabase logs now surface, without leaking student IDs or the service email that the Supabase client emits at `debug`. - deploy.yml: after `up -d`, assert the container is actually Running 30s later and dump its logs and fail if not — `up -d` returns 0 on container creation, not on a working process. - Dockerfile: pin the builder to rust:1-bookworm to match the bookworm-slim runtime, removing the trixie/bookworm glibc mismatch. - README: document the info-level default and the RUST_LOG=debug PII footgun. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017XrE7F9ZuBWdQnS8CZvYDE
70 lines
2.2 KiB
YAML
70 lines
2.2 KiB
YAML
name: Docker Compose Deploy
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
# Manual re-run, for redeploying after a rollback or re-creating the
|
|
# workspace .env that the cleanup step below now removes.
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
build_and_deploy:
|
|
runs-on: [self-hosted, linux]
|
|
# SEC-01: this gates nothing until required reviewers are configured on the
|
|
# "production" environment itself. See the pull request description.
|
|
environment: production
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
|
|
with:
|
|
clean: true
|
|
fetch-depth: 1
|
|
|
|
- name: Create environment file
|
|
working-directory: ${{ github.workspace }}
|
|
env:
|
|
DOT_ENV: ${{ secrets.DOT_ENV }}
|
|
run: |
|
|
if [ -z "$DOT_ENV" ]; then
|
|
echo "DOT_ENV secret is missing or empty."
|
|
exit 1
|
|
fi
|
|
|
|
umask 077
|
|
printf '%s\n' "$DOT_ENV" > .env
|
|
|
|
- name: Build and deploy
|
|
working-directory: ${{ github.workspace }}
|
|
run: |
|
|
sudo docker compose up -d --build --force-recreate
|
|
echo "Container created."
|
|
|
|
# `docker compose up -d` exits 0 once the container is created, not once the
|
|
# program inside is running. The bot can panic at boot (a bad .env value, a
|
|
# Supabase hiccup) and exit within a second while the deploy still goes green.
|
|
# Assert the container is actually alive, and surface its logs if not (OPS-04).
|
|
- name: Verify the bot is still running
|
|
working-directory: ${{ github.workspace }}
|
|
run: |
|
|
sleep 30
|
|
id=$(sudo docker compose ps -q dsec_bot)
|
|
running=$(sudo docker inspect -f '{{.State.Running}}' "$id")
|
|
if [ "$running" != "true" ]; then
|
|
echo "::error::dsec_bot is not running 30s after deploy"
|
|
sudo docker compose logs --tail=100 dsec_bot
|
|
exit 1
|
|
fi
|
|
echo "Deployment complete."
|
|
|
|
- name: Remove environment file
|
|
if: always()
|
|
working-directory: ${{ github.workspace }}
|
|
run: rm -f .env
|
|
|
|
- name: Clean up old Docker images
|
|
run: sudo docker image prune -f
|