| name | longjin-ship-deploy |
| description | Ship longjin-api changes through the standard production path: ask the user after implementation, then commit, push main, wait for GHCR image build, and redeploy AWS-HK longjin-api (longjinapi.com). Use when finishing a feature or fix for this repo, when the user says 提交推送/部署/上线/发布, when verifying on longjinapi.com, or when working with aws-hk / GHCR longjin-api:beta. |
Longjin Ship & Deploy
Mandatory gate (do this after every meaningful code change)
Most changes need production verification. Do not silently stop after coding.
When implementation for the current request is done (or the user asks to ship):
- Briefly summarize what changed.
- Ask whether to run the ship flow below.
- Recommended default prompt (Chinese is fine):
代码已改完。是否执行:提交 → 推送 main → 等 GitHub 镜像构建 → 部署到 AWS-HK(longjinapi.com)?
- Only run the flow after explicit approval (
是 / 部署 / 提交推送 / 继续发布 等).
- If the user says no, stop and leave a clean summary of local changes.
Skip the ask only when the user already ordered ship in the same turn (e.g. “提交推送并部署”), or the change is docs/skill-only with no runtime impact and they did not ask to deploy.
Production targets (longjin-api)
| Item | Value |
|---|
| Repo | dev-longshun/longjinApi |
| Image | ghcr.io/dev-longshun/longjin-api:beta |
| CI workflow | Build and Push Docker Image (.github/workflows/docker-build.yml) |
| Trigger | push to main (also tags / workflow_dispatch) |
| Server notes | /Users/longshun/Desktop/Program/00_use/vps/aws-hk/README.md |
| Host | root@95.40.218.190 |
| SSH key | /Users/longshun/Desktop/Program/00_use/vps/aws-hk/codex-aws-hk-ed25519 |
| Compose dir | /root/longjin-api |
| Domain | https://longjinapi.com |
| App port | host 3001 → container 3000 |
Do not print DB passwords or full compose secrets in chat. Prefer redacting DSN credentials.
Ship flow
1. Preflight
git status / git diff / recent git log — only commit intended files.
- Do not commit secrets, local-only paths, or unrelated dirty files.
- Prefer a short, complete-sentence commit message describing why.
2. Commit + push
git add <files>
git commit -m "$(cat <<'EOF'
<type>(scope): <summary>
EOF
)"
git push origin main
- Follow repo commit rules (no force-push to main, no amending published commits unless asked).
- Confirm
git status is clean and tracking origin/main.
3. Wait for image build
gh run list --repo dev-longshun/longjinApi --workflow "Build and Push Docker Image" --limit 3
gh run watch <run_id> --repo dev-longshun/longjinApi --exit-status
gh api repos/dev-longshun/longjinApi/actions/runs/<run_id> --jq '{status,conclusion,html_url}'
- Success means multi-arch build + manifest pushed
longjin-api:beta (and beta-<shortsha>).
- On failure: stop, surface the run URL and failed job logs; do not deploy an old/partial image.
4. Deploy on AWS-HK
SSH_KEY="/Users/longshun/Desktop/Program/00_use/vps/aws-hk/codex-aws-hk-ed25519"
ssh -i "$SSH_KEY" -o StrictHostKeyChecking=accept-new -o ConnectTimeout=20 root@95.40.218.190 '
set -e
cd /root/longjin-api
docker compose pull longjin-api
docker compose up -d --no-deps longjin-api
'
- Use
--no-deps so Postgres/Redis are not recreated.
- After recreate, wait until the app is ready (a few seconds is often not enough).
5. Verify
On the server:
curl -sS -o /dev/null -w "%{http_code}\n" http://127.0.0.1:3001/
curl -sS -o /dev/null -w "%{http_code}\n" http://127.0.0.1:3001/api/status
docker logs --tail 30 longjin-api
docker inspect longjin-api --format 'Image={{.Config.Image}} Id={{.Image}} Status={{.State.Status}}'
Optionally HTTPS:
curl -sS -o /dev/null -w "%{http_code}\n" --resolve longjinapi.com:443:127.0.0.1 https://longjinapi.com/
curl -sS -o /dev/null -w "%{http_code}\n" https://longjinapi.com/api/status
Expect logs similar to 火山API beta-<sha> ready matching the pushed commit.
6. Report back
Include:
- Commit SHA + one-line summary
- GH Actions run URL + success
- Deploy host + that only
longjin-api was recreated
- Health check results for local and
longjinapi.com
Failure handling
| Stage | Action |
|---|
| Commit/push rejected | Fix and retry; never force-push main unless user explicitly asks |
| CI failed | Do not deploy; link failed job; fix and re-run ship flow |
| Pull failed (auth/network) | Check GHCR auth on server (~/.docker/config.json); retry pull |
| Container unhealthy | docker logs longjin-api; do not “fix” by wiping volumes |
| Curl 000 / connection reset right after start | Wait and retry 10–40s before declaring failure |
Out of scope
- Other apps on the same host (new-api, shop, ghost, etc.) unless the user names them.
- DNS/cert changes unless the user asks.
- Building images locally when CI already publishes
beta.
Quick checklist