English
Checkpoint
What must work
On your computer:
powershell
curl.exe https://<your domain>/healthOn the server:
bash
readlink /opt/chatex/currentbash
cat /opt/chatex/current/REVISIONbash
systemctl status chatex-apiYour repository is now complete. Compare the last two folders with the reference:
powershell
git diff --no-index --stat .github D:\Work\Chatex-Reference\.githubpowershell
git diff --no-index --stat Deploy D:\Work\Chatex-Reference\DeployThe first prints nothing; the second lists only nginx/chatex.conf, where your server_name differs.
The workflow and the script were committed in their chapters, and dev was merged into main for the first deployment; git status reports a clean working tree.
The tutorial is complete: Chatex runs in production, and every further change travels the same road — a branch, CI, a pull request, a merge, an approval, an automatic and reversible deployment.
Common mistakes
Table 24.2. Common mistakes in continuous deployment
| Symptom | Cause | Fix |
|---|---|---|
Set up SSH fails with SSH_KNOWN_HOSTS contains no host key lines | the secret is empty, belongs to another environment, or has only the comment line | paste the line <droplet ip> ssh-ed25519 AAAA… from ssh-keyscan |
Upload release fails with Host key verification failed. | the pinned host key does not match the server (wrong IP, rebuilt server) | compare the fingerprints printed by Set up SSH, update SSH_KNOWN_HOSTS |
Upload release fails with Permission denied (publickey). | the public deploy key is not in /root/.ssh/authorized_keys, or SSH_PRIVATE_KEY is not the matching private key | append chatex-deploy.pub on the server; paste the whole private key file into the secret |
Load key "/home/runner/.ssh/deploy_key": error in libcrypto | the private key secret is incomplete (missing -----BEGIN/-----END lines) | paste the complete file chatex-deploy |
[chatex-activate] error: ConnectionStrings__Chatex is not set in /etc/chatex/chatex.env | the line is missing or misspelled in the settings file | fix /etc/chatex/chatex.env and run Run workflow |
health check failed, rolling back … and DataAnnotation validation failed for 'JwtOptions' members: 'SigningKey' … in the journal | the signing key is shorter than 32 characters | put a key from openssl rand -base64 48 into the settings file |
Smoke test fails with curl: (22) The requested URL returned error: 400 | AllowedHosts does not contain your domain | add the domain in /etc/chatex/chatex.env, systemctl restart chatex-api |
No DbContext named 'Release' was found. when deploying by hand | -c Release was used with dotnet ef, where -c means --context | use --configuration Release |
Self-check questions
- What is the difference between continuous delivery and continuous deployment, and which one does Chatex do?
- Why does
deploy.ymlcallci.ymlagain, although the pull request was already checked? - Why is the concurrency group
productionnot cancelled in progress, while CI runs are? - What does the package job produce, and why is nothing built on the server?
- Why is the API published framework-dependent? What would change with a self-contained publish?
- What is a migration bundle, and why does the server need neither the SDK nor the source code to migrate?
- Why does the activation script check that its argument looks like a commit hash?
- Why are migrations applied before the switch, and why must they stay compatible with the previous release?
- How does the script switch
currentatomically, and why not simply withln -sfn? - What exactly happens when the new release does not answer
/healthwithin 30 seconds? - Why does the runner get its own deploy key and a pinned host key, and what does
StrictHostKeyChecking yesprevent? - Which values are secrets and which is a variable? When does the deploy job receive the secrets?
- How do you roll back by hand, and what does a rollback not undo?
- What happens to signed-in users when the JWT signing key is replaced?
Exercises
- A visible release. Change a text in the client on
dev, for example the description inindex.html, merge it intomainand follow the deployment from the merge to the browser. Measure how long each job takes and how long the API is unavailable during the restart (journalctlshows the times). - The first-deployment edge case. Fix the edge case described in Activating a release:
PREVIOUSmust be empty whencurrentdoes not exist yet. Whichreadlinkoption does that, and how do you test the change without breaking the server (hint: a copy of the script and a fake release that fails)? - Show the version. Make the deployed version visible: let the API read
REVISIONfrom its release folder and return it from a new anonymous endpoint, or let Nginx serveREVISIONas/version.txt. Which solution exposes less, and does the CSP or the caching configuration need a change? - A zero-downtime deployment (design only). During
systemctl restartthe API is down for a few seconds. Sketch how two services on two ports and an Nginxupstreamswitch could avoid that. Why is this harder for Chatex than for a stateless API (think of the online status in memory and the SignalR connections)?