Skip to content

Deploy with a deploy key, a trial run and a full rollback - #14

Merged
andersgar merged 3 commits into
mainfrom
auto-deploy
Oct 6, 2026
Merged

andersgar merged 3 commits into
mainfrom
auto-deploy

Conversation

@andersgar

Copy link
Copy Markdown
Contributor

Fetches main with a read-only deploy key instead of a token. The new image is tried on a copy of the database before the real container is replaced, and a rollback restores files, image and database. Adds /version, which the Deploy workflow uses to record each deploy on GitHub. Fixes the three review findings on #13.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Unresolved deployment safety, rollback, trial-isolation, host-key, and workflow timeout issues remain.

Review effort: Lite
Findings: 2 High severity · 1 Medium severity

Open (3)
What changed in this PR

Adds deploy-key-based deployments with trial validation, rollback support, and GitHub deployment tracking through /version.

Changes:

  • Adds /version and deployment metadata handling.
  • Reworks deployment with database trials, health checks, and rollback.
  • Updates deployment documentation and GitHub Actions monitoring.
File Description
src/​server.ts Adds /version.
README.md Documents the endpoint.
docker-compose.yaml Loads deployment metadata.
deploy/​README.md Documents deployment setup and behavior.
deploy/​deploy.sh Implements fetching, trials, deployment, and rollback.
deploy/​deploy.env.example Defines deploy-key configuration.
.github/​workflows/​deploy.yml Records and monitors deployments.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread deploy/deploy.sh Outdated
Comment thread deploy/deploy.sh Outdated
Comment thread deploy/deploy.sh Outdated
@andersgar
andersgar requested a lite review from Copilot October 6, 2026 07:58
@andersgar
andersgar merged commit 7fdc9f3 into main Oct 6, 2026
2 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Critical rollback and database-consistency issues remain, along with synchronization and workflow-timeout defects.

Review effort: Lite
Findings: 2 High severity · 1 Medium severity

Open (3)
Resolved since last review (3)
Previously missed (2)

In code that hasn't changed since last review

Medium severity Polling loop can exceed job timeout

.github/​workflows/​deploy.yml:47

The polling loop can run for up to 45 × (10 seconds for curl --max-time + 20 seconds of sleep) = 1,350 seconds, which is 22.5 minutes. That exceeds the job's 20-minute timeout and contradicts the 15-minute failure message, so a slow/unreachable endpoint can cancel the job before this workflow reports a failure. Reduce the iteration bound or otherwise make the loop's worst-case duration fit both limits.

Medium severity Cleanup deletes operator-owned empty directories

deploy/​deploy.sh:53

This cleanup scans all of APP_DIR, not just directories that belonged to the previous commit. It therefore deletes any empty operator-owned directory, despite the surrounding contract that files and directories the repository does not own stay untouched. Restrict the directory cleanup to parent directories of the files removed from the Git tree (or to repository-owned roots).

Comment thread deploy/deploy.sh
# container is touched
uid=$(docker run --rm --entrypoint id "$IMAGE:latest" -u)
install -d -m 700 -o "$uid" "$WORK/trial"
install -m 600 -o "$uid" "$BACKUP_DIR/db-$STAMP.db" "$WORK/trial/tebonsma.db"
Comment thread deploy/deploy.sh
check_api "$TRIAL" || fail "the trial run of the new version does not answer as expected"
docker rm -f "$TRIAL" >/dev/null

REAL_STARTED=1
Comment thread deploy/deploy.sh
remove_tree "$DEPLOYED"
else
log "previous commit unknown; clearing the repository's folders"
for dir in src dev test deploy .github; do rm -rf "${APP_DIR:?}/$dir"; done
@andersgar
andersgar deleted the auto-deploy branch October 6, 2026 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants