Menu
Public repository / 1a9e82dde55323be1dbcafc350f7d90a24175917
AkurAI-Notes / .akurai.yml
Latest change 1a9e82dde55323be1dbcafc350f7d90a24175917 - Wire akurai-log Monitor shipper into the server command by Ólafur Búi Ólafsson
version: 1
jobs:
- name: lint-config
executor: native
branches: [master]
run:
- sh scripts/test-lint-akurai-yml.sh
- sh scripts/test-lint-sibling-deps.sh
- sh scripts/lint-akurai-yml.sh .akurai.yml
- sh scripts/lint-sibling-deps.sh
- name: verify
needs: [lint-config]
executor: native
branches: [master]
run:
- rm -rf ../AkurAI-Framework; git clone --quiet --no-checkout $AKURAI_BUILD_DATA/hosted/AkurAI-Framework.git ../AkurAI-Framework; git -C ../AkurAI-Framework checkout --quiet --detach 6773bf3b2333914e30899245eaf1e789211fa835; test "$(git -C ../AkurAI-Framework rev-parse HEAD)" = 6773bf3b2333914e30899245eaf1e789211fa835
- rm -rf ../akurai-log; git clone --quiet --no-checkout $AKURAI_BUILD_DATA/hosted/akurai-log.git ../akurai-log; git -C ../akurai-log checkout --quiet --detach 3c855deb0cc56ae117c336ca1f5ffd8ab54c710e; test "$(git -C ../akurai-log rev-parse HEAD)" = 3c855deb0cc56ae117c336ca1f5ffd8ab54c710e
- RUSTUP_HOME=$AKURAI_HOST_HOME/.rustup CARGO_HOME=$AKURAI_HOST_HOME/.cargo PATH=$AKURAI_HOST_HOME/.cargo/bin:/usr/bin:/bin cargo fmt --all -- --check
- RUSTUP_HOME=$AKURAI_HOST_HOME/.rustup CARGO_HOME=$AKURAI_HOST_HOME/.cargo PATH=$AKURAI_HOST_HOME/.cargo/bin:/usr/bin:/bin cargo clippy --all-targets --all-features -- -D warnings
- RUSTUP_HOME=$AKURAI_HOST_HOME/.rustup CARGO_HOME=$AKURAI_HOST_HOME/.cargo PATH=$AKURAI_HOST_HOME/.cargo/bin:/usr/bin:/bin cargo test --all
- name: package
needs: [verify]
executor: native
branches: [master]
run: RUSTUP_HOME=$AKURAI_HOST_HOME/.rustup CARGO_HOME=$AKURAI_HOST_HOME/.cargo PATH=$AKURAI_HOST_HOME/.cargo/bin:/usr/bin:/bin cargo build --release --target x86_64-unknown-linux-musl -p akurai-notes
artifacts:
- target/x86_64-unknown-linux-musl/release/akurai-notes
# Deployment is codified here (no deploy.sh): ship the packaged binary + site
# assets and the committed systemd unit / nginx vhost to EC2 over the mesh SSH
# alias, restart, roll back on a failed self healthcheck, then run the shared
# cross-environment health sweep (fails on self-unhealthy, warns on other-env
# regressions).
- name: deploy
needs: [package]
executor: native
environment: production
approval: true
branches: [master]
run: |
export HOME=$AKURAI_HOST_HOME
export PATH=$AKURAI_HOST_HOME/.local/bin:/usr/bin:/bin
HOST=akurai-ec2
BIN=target/x86_64-unknown-linux-musl/release/akurai-notes
test -f "$BIN" || { echo "missing packaged binary: $BIN" >&2; exit 1; }
echo "==> ship binary (backup previous)"
scp -q "$BIN" "$HOST:/tmp/akurai-notes.new"
ssh "$HOST" 'sudo mkdir -p /opt/akurai-notes/bin /var/lib/akurai-notes /etc/akurai-notes && { [ -f /opt/akurai-notes/bin/akurai-notes ] && sudo cp -p /opt/akurai-notes/bin/akurai-notes /opt/akurai-notes/bin/akurai-notes.prev || true; } && sudo install -m 755 -o ubuntu -g ubuntu /tmp/akurai-notes.new /opt/akurai-notes/bin/akurai-notes && rm -f /tmp/akurai-notes.new'
echo "==> ship site assets"
tar czf - -C site . | ssh "$HOST" 'sudo rm -rf /opt/akurai-notes/app && sudo mkdir -p /opt/akurai-notes/app && sudo tar xzf - -C /opt/akurai-notes/app && sudo chown -R ubuntu:ubuntu /opt/akurai-notes/app'
echo "==> systemd unit"
scp -q deploy/akurai-notes.service "$HOST:/tmp/akurai-notes.service"
ssh "$HOST" 'sudo install -m 644 /tmp/akurai-notes.service /etc/systemd/system/akurai-notes.service && rm -f /tmp/akurai-notes.service && sudo systemctl daemon-reload && sudo systemctl enable akurai-notes.service'
echo "==> nginx vhost"
scp -q deploy/akurai-notes.nginx.conf "$HOST:/tmp/akurai-notes.nginx"
ssh "$HOST" 'sudo install -m 644 /tmp/akurai-notes.nginx /etc/nginx/sites-available/akurai-notes.olibuijr.com && sudo ln -sf /etc/nginx/sites-available/akurai-notes.olibuijr.com /etc/nginx/sites-enabled/akurai-notes.olibuijr.com && rm -f /tmp/akurai-notes.nginx && sudo nginx -t && sudo systemctl reload nginx'
echo "==> env guard (secrets are provisioned out of band)"
ssh "$HOST" 'sudo test -f /etc/akurai-notes/notes.env'
echo "==> restart service"
ssh "$HOST" 'sudo systemctl restart akurai-notes.service'
echo "==> self healthcheck (rollback on failure)"
sleep 3
if ! ssh "$HOST" 'curl -fsS http://127.0.0.1:8099/api/health' >/dev/null; then
echo "self health failed; rolling back to previous binary" >&2
ssh "$HOST" 'sudo cp -p /opt/akurai-notes/bin/akurai-notes.prev /opt/akurai-notes/bin/akurai-notes && sudo systemctl restart akurai-notes.service'
exit 1
fi
code="$(ssh "$HOST" 'curl -sS -o /dev/null -w "%{http_code}" http://127.0.0.1:8099/mcp')"
test "$code" = "405" || { echo "mcp endpoint expected 405, got $code" >&2; exit 1; }
echo "==> cross-environment health sweep"
akurai-health-sweep --self akurai-notes