Run tests and deploy in one Gitea Actions job
Test and deploy / test-and-deploy (pull_request) Successful in 33s
Test and deploy / test-and-deploy (pull_request) Successful in 33s
Two jobs meant checking out, setting up Node and running npm ci (and in the frontend the build) twice, about two minutes each, because every job starts in a fresh container. Now one job tests and, for pushes to master only, deploys. The push-to-master condition is spelled out on every deploy step instead of an env flag compared to 'true', which would skip the deploy silently and stay green if the boolean were rendered differently. A failed test still stops the deploy (an if: without a status function implies success()). Docs: the one-job layout, and that Jenkins deployed as root - files it left in an app folder must be chowned to the subscription user before the first Gitea deploy (hit on the API). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2 files changed
+41
-25
No files matched your search
+18
-4
@@ -8,12 +8,13 @@ Node.js App").
|
||||
|
||||
```
|
||||
push to master ──▶ Gitea ──▶ runner (container on the server)
|
||||
├─ test job: npm ci, tsc --noEmit, npm test (unit tests)
|
||||
└─ deploy job: npm ci, build, prune dev deps ─ rsync over SSH ─▶
|
||||
└─ one job: npm ci, tsc --noEmit, npm test (unit tests)
|
||||
└─ (master only) build, prune dev deps ─ rsync over SSH ─▶
|
||||
plesk-nachklang@nachklang.art:<app root> + tmp/restart.txt
|
||||
```
|
||||
|
||||
Pull requests only run the test job.
|
||||
Pull requests run the same job up to the tests; the deploy steps only run for pushes to master. It
|
||||
used to be two jobs, which ran `npm ci` twice (~2 min each); merged into one on 2026-11-08.
|
||||
|
||||
## Plesk (as configured, 2026-11-08)
|
||||
|
||||
@@ -69,8 +70,14 @@ is the one nachklang.art itself depends on.
|
||||
## Switchover (done once)
|
||||
|
||||
1. Pause the Jenkins API job (done 2026-11-08).
|
||||
1a. **Fix file ownership** (as root): Jenkins deployed as **root**, so `dist/`, `src/` and
|
||||
`node_modules/` were `root:root`, and the first Gitea deploy failed with rsync "Operation not
|
||||
permitted" / "Permission denied" - the subscription user can't change root's files. Fixed with
|
||||
`chown -R plesk-nachklang:psacln dist src node_modules` in the app root (the group of the files
|
||||
the app creates itself, e.g. `.env`, `logs/`); then re-run the failed job.
|
||||
Check: `find . ! -user plesk-nachklang` prints nothing.
|
||||
2. Set `DEPLOY_PATH` and `DEPLOY_SMOKE_URL`.
|
||||
3. Open a PR → green test job → merge → watch the deploy job. Unlike the calendar there is no gap:
|
||||
3. Open a PR → green run → merge → watch the deploy steps. Unlike the calendar there is no gap:
|
||||
the folder keeps working while files are replaced, and Passenger restarts on the next request.
|
||||
4. Check `https://api.nachklang.art/docs` and the calendar/feedback/tickets apps.
|
||||
|
||||
@@ -93,6 +100,13 @@ Not checked: the workflow on the real runner.
|
||||
|
||||
## Notes
|
||||
|
||||
- There was **no `package.json` on the server** before the first rsync deploy (Jenkins never copied
|
||||
it); `dist/app.js` still ran as ES modules, probably because Node ≥ 22 detects ES module syntax on
|
||||
its own [inference, not checked]. The deploy now ships `package.json`, so it doesn't depend on that.
|
||||
- A failed upload leaves new and old files mixed in `dist/`, but the running app is unaffected:
|
||||
the restart step is skipped, so Passenger keeps the old code in memory until the next deploy (or an
|
||||
unplanned restart - fix and re-run soon).
|
||||
|
||||
- `bcrypt` was removed on 2026-11-08: nothing imported it any more (passwords moved to better-auth,
|
||||
which hashes with its own scrypt). It was the only production dependency with a native build step.
|
||||
- `FEEDBACK_IP_SALT`, which the Jenkins test step exported, isn't needed in CI: `vitest.config.ts`
|
||||
|
||||
Reference in new issue
Block a user