agentbbs/.github/workflows/deploy.yml
dependabot[bot] c465a96cdb
chore(deps): bump the github-actions group with 5 updates (#175)
Bumps the github-actions group with 5 updates:

| Package | From | To |
| --- | --- | --- |
| [actions/checkout](https://github.com/actions/checkout) | `4.4.0` | `7.0.1` |
| [actions/setup-node](https://github.com/actions/setup-node) | `4.4.0` | `7.1.0` |
| [actions/upload-artifact](https://github.com/actions/upload-artifact) | `4.6.2` | `7.0.2` |
| [github/codeql-action/upload-sarif](https://github.com/github/codeql-action) | `3.37.7` | `4.39.4` |
| [actions/github-script](https://github.com/actions/github-script) | `7.1.0` | `9.0.0` |


Updates `actions/checkout` from 4.4.0 to 7.0.1
- [Release notes](https://github.com/actions/checkout/releases)
- [Commits](https://github.com/actions/checkout/compare/v4.4.0...v7.0.1)

Updates `actions/setup-node` from 4.4.0 to 7.1.0
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](49933ea528...949feb2413)

Updates `actions/upload-artifact` from 4.6.2 to 7.0.2
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](ea165f8d65...cf430e030d)

Updates `github/codeql-action/upload-sarif` from 3.37.7 to 4.39.4
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](f3712979fa...1bd86f2fdb)

Updates `actions/github-script` from 7.1.0 to 9.0.0
- [Release notes](https://github.com/actions/github-script/releases)
- [Commits](f28e40c7f3...3a2844b7e9)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 7.0.1
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: actions/setup-node
  dependency-version: 7.1.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: actions/upload-artifact
  dependency-version: 7.0.2
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: github/codeql-action/upload-sarif
  dependency-version: 4.39.4
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
- dependency-name: actions/github-script
  dependency-version: 9.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: github-actions
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-11-27 00:29:44 -08:00

153 lines
7.2 KiB
YAML

name: deploy
# Fully autonomous, idempotent deploy. On every push to main (or manual
# dispatch) this builds the Go binaries ON THE RUNNER (which has plenty of
# RAM), ships them to the bbs.profullstack.com droplet, and re-runs the
# idempotent provisioner (setup.sh) with SKIP_BUILD=1 so the tiny droplet
# never has to compile. setup.sh still pulls origin, refreshes config/assets,
# and restarts the agentbbs service that answers `ssh join@bbs.profullstack.com`.
# Re-running is always safe.
#
# Why build on the runner: the droplet is a ~458MB box also running ergo,
# forgejo, tor, podman and the live agentbbs. The Go linker's peak memory was
# OOM-killing the build — and with it the sshd serving the deploy session,
# surfacing as "Connection closed by remote host" (exit 255). Compiling on the
# 16GB runner removes that failure mode entirely.
#
# Required repo secrets (Settings -> Secrets and variables -> Actions):
# DEPLOY_SSH_KEY private key whose public half is in root's authorized_keys
# pinned to ONE forced command:
# restrict,command="/usr/local/sbin/agentbbs-ci-deploy" ssh-ed25519 ...
# (deploy/ci-deploy.sh, installed by setup.sh). The key gets
# no shell, scp, sftp, pty or forwarding; it can only run
# `arch`, `upload <binary>` (stdin) and `deploy <branch>`.
# DEPLOY_HOST bbs.profullstack.com (or the droplet's public IP)
# Optional (have sensible defaults below):
# DEPLOY_USER admin SSH user (default: root)
# DEPLOY_PORT admin SSH port (default: 2202 — setup.sh moves OpenSSH here)
on:
push:
branches: [main, master]
workflow_dispatch:
# Never let two deploys overlap; setup.sh also self-locks, this is belt+braces.
concurrency:
group: deploy-production
cancel-in-progress: false
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7.0.1
- name: Configure SSH
env:
DEPLOY_SSH_KEY: ${{ secrets.DEPLOY_SSH_KEY }}
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
DEPLOY_PORT: ${{ secrets.DEPLOY_PORT || '2202' }}
run: |
test -n "$DEPLOY_SSH_KEY" || { echo "::error::DEPLOY_SSH_KEY secret is not set"; exit 1; }
test -n "$DEPLOY_HOST" || { echo "::error::DEPLOY_HOST secret is not set"; exit 1; }
install -d -m 700 ~/.ssh
printf '%s\n' "$DEPLOY_SSH_KEY" > ~/.ssh/id_deploy
chmod 600 ~/.ssh/id_deploy
ssh-keyscan -p "$DEPLOY_PORT" -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts 2>/dev/null
- name: Detect droplet architecture
id: arch
env:
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
DEPLOY_USER: ${{ secrets.DEPLOY_USER || 'root' }}
DEPLOY_PORT: ${{ secrets.DEPLOY_PORT || '2202' }}
run: |
uname_m="$(ssh -i ~/.ssh/id_deploy -p "$DEPLOY_PORT" \
-o BatchMode=yes -o StrictHostKeyChecking=yes \
"${DEPLOY_USER}@${DEPLOY_HOST}" arch)"
case "$uname_m" in
x86_64|amd64) goarch=amd64 ;;
aarch64|arm64) goarch=arm64 ;;
*) echo "::error::unsupported droplet arch '$uname_m'"; exit 1 ;;
esac
echo "goarch=$goarch" >> "$GITHUB_OUTPUT"
echo "::notice::droplet arch $uname_m -> GOARCH=$goarch"
- uses: actions/setup-go@v7
with:
go-version-file: go.mod
cache: true
- name: Build binaries (on the runner, not the droplet)
env:
GOOS: linux
GOARCH: ${{ steps.arch.outputs.goarch }}
CGO_ENABLED: '0' # pure-Go (modernc sqlite) — static, portable binary
run: |
mkdir -p dist
go build -trimpath -o dist/agentbbs ./cmd/agentbbs
go build -trimpath -o dist/ascii-live ./cmd/ascii-live
file dist/* || true
- name: Ship binaries to the droplet
env:
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
DEPLOY_USER: ${{ secrets.DEPLOY_USER || 'root' }}
DEPLOY_PORT: ${{ secrets.DEPLOY_PORT || '2202' }}
run: |
# The forced command reads each binary from stdin (no scp/sftp).
for b in agentbbs ascii-live; do
ssh -i ~/.ssh/id_deploy -p "$DEPLOY_PORT" \
-o BatchMode=yes -o StrictHostKeyChecking=yes \
"${DEPLOY_USER}@${DEPLOY_HOST}" "upload $b" < "dist/$b"
done
- name: Provision / redeploy (idempotent, SKIP_BUILD=1)
env:
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
DEPLOY_USER: ${{ secrets.DEPLOY_USER || 'root' }}
DEPLOY_PORT: ${{ secrets.DEPLOY_PORT || '2202' }}
# Deploy whichever branch was pushed (main or master), so a rename
# "just works". For workflow_dispatch this is the chosen branch.
DEPLOY_BRANCH: ${{ github.ref_name }}
# App secrets injected into the droplet's env file by setup.sh.
# GitHub masks these in logs; setup.sh upserts them idempotently.
COINPAY_API_KEY: ${{ secrets.COINPAY_API_KEY }}
COINPAY_MERCHANT_ID: ${{ secrets.COINPAY_MERCHANT_ID }}
AGENTBBS_QRYPT_ISSUER_KEY: ${{ secrets.AGENTBBS_QRYPT_ISSUER_KEY }}
run: |
# The forced command (deploy/ci-deploy.sh) syncs /opt/agentbbs to
# origin/$DEPLOY_BRANCH, installs the uploaded binaries, pauses the
# self-update timer and execs setup.sh with SKIP_BUILD=1. App secrets
# travel on stdin as NAME=<base64> lines, never on the command line.
case "$DEPLOY_BRANCH" in main|master) ;; *) echo "::error::refusing to deploy $DEPLOY_BRANCH"; exit 1 ;; esac
for k in COINPAY_API_KEY COINPAY_MERCHANT_ID AGENTBBS_QRYPT_ISSUER_KEY; do
printf '%s=%s\n' "$k" "$(printf '%s' "${!k}" | base64 -w0)"
done | ssh -i ~/.ssh/id_deploy -p "$DEPLOY_PORT" \
-o BatchMode=yes -o StrictHostKeyChecking=yes \
"${DEPLOY_USER}@${DEPLOY_HOST}" "deploy $DEPLOY_BRANCH"
- name: Smoke-test that agentbbs serves :22
if: success()
env:
DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }}
run: |
# Confirm an SSH server answers on :22 WITHOUT authenticating — a real
# join@ connection would register the connecting key as a new account,
# so we never complete a handshake here. Admin OpenSSH lives on the
# admin port, so anything serving :22 is agentbbs answering join@/bbs@.
#
# Retry: the redeploy above restarts agentbbs, and this step can start
# before it has re-bound :22. A single probe failed most deploys
# (red runs with the BBS answering fine moments later), so give it
# up to ~2 minutes and fail only if it never comes back.
for attempt in $(seq 1 12); do
if timeout 15 ssh-keyscan -T 10 -p 22 "$DEPLOY_HOST" 2>/dev/null | grep -q .; then
echo "::notice::agentbbs is serving SSH on ${DEPLOY_HOST}:22 (join@ is reachable, attempt ${attempt})"
exit 0
fi
echo "attempt ${attempt}/12: nothing on ${DEPLOY_HOST}:22 yet, retrying in 10s"
sleep 10
done
echo "::error::nothing is serving SSH on ${DEPLOY_HOST}:22 after 12 attempts — agentbbs may be down"
exit 1