chore: version-control the production deploy script
Moves the deploy script off the server and into the repo as scripts/update-app.sh, with the two fixes made during the v1.114.0 deploy: - set -euo pipefail, so a failed git pull aborts instead of rebuilding and restarting PM2 on unchanged code while printing "Update Complete" - npm ci instead of npm install, which rewrote package-lock.json and left the tree dirty so the next git pull aborted The body is wrapped in a main() function because the script lives inside the checkout it updates, and git pull rewriting it mid-run would leave bash reading from a stale file offset. v1.114.1 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
7e3e30ec83
commit
3338978163
@ -2,6 +2,15 @@
|
|||||||
|
|
||||||
All notable changes to this project are documented in this file.
|
All notable changes to this project are documented in this file.
|
||||||
|
|
||||||
|
## [1.114.1] - 2026-09-01
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- `scripts/update-app.sh`: the production deploy script, now version-controlled instead of
|
||||||
|
living only on the server. Hardened with `set -euo pipefail` (a failed `git pull` used to
|
||||||
|
still trigger a rebuild and PM2 restart on unchanged code) and switched from `npm install`
|
||||||
|
to `npm ci` (npm install rewrote package-lock.json, leaving the tree dirty so the next
|
||||||
|
pull aborted).
|
||||||
|
|
||||||
## [1.114.0] - 2026-09-01
|
## [1.114.0] - 2026-09-01
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "my-weekly-todo-list",
|
"name": "my-weekly-todo-list",
|
||||||
"version": "1.114.0",
|
"version": "1.114.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "my-weekly-todo-list",
|
"name": "my-weekly-todo-list",
|
||||||
"version": "1.114.0",
|
"version": "1.114.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@auth/prisma-adapter": "^2.11.1",
|
"@auth/prisma-adapter": "^2.11.1",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "my-weekly-todo-list",
|
"name": "my-weekly-todo-list",
|
||||||
"version": "1.114.0",
|
"version": "1.114.1",
|
||||||
"description": "A web-based weekly task management application that organizes to-dos and calendar events in a single, intuitive weekly view",
|
"description": "A web-based weekly task management application that organizes to-dos and calendar events in a single, intuitive weekly view",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
47
scripts/update-app.sh
Normal file
47
scripts/update-app.sh
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Deploy script for the production host (WebApp-Testing-live).
|
||||||
|
#
|
||||||
|
# The app runs there as a PM2 process ("my-weekly-todo") from /root/My-Weekly-ToDo-List.
|
||||||
|
# It is NOT run under Docker — deploy.sh and docker-compose.yml in this repo describe an
|
||||||
|
# older Portainer setup that is not what serves todo.martin-bierschenk.de.
|
||||||
|
#
|
||||||
|
# Usage on the host: /root/My-Weekly-ToDo-List/scripts/update-app.sh
|
||||||
|
#
|
||||||
|
# The whole body is wrapped in a function so bash parses it in one go: this script lives
|
||||||
|
# inside the very checkout it updates, and `git pull` rewriting it mid-run would otherwise
|
||||||
|
# make bash resume at a stale file offset.
|
||||||
|
|
||||||
|
main() {
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Fail fast instead of hanging on a credential prompt when run without a terminal
|
||||||
|
# (e.g. from systemd). The host authenticates via a read-only SSH deploy key.
|
||||||
|
export GIT_TERMINAL_PROMPT=0
|
||||||
|
|
||||||
|
local APP_DIR="/root/My-Weekly-ToDo-List"
|
||||||
|
local PM2_APP="my-weekly-todo"
|
||||||
|
|
||||||
|
cd "$APP_DIR"
|
||||||
|
|
||||||
|
echo "--- Pulling latest changes from git ---"
|
||||||
|
git pull origin main
|
||||||
|
|
||||||
|
# npm ci, not npm install: it installs exactly what package-lock.json specifies and
|
||||||
|
# never rewrites it. npm install rewrites the lockfile, which leaves the working tree
|
||||||
|
# dirty and makes the *next* git pull abort.
|
||||||
|
echo "--- Installing dependencies ---"
|
||||||
|
npm ci
|
||||||
|
|
||||||
|
echo "--- Building application ---"
|
||||||
|
npm run build
|
||||||
|
|
||||||
|
echo "--- Restarting PM2 process ---"
|
||||||
|
pm2 restart "$PM2_APP" --update-env
|
||||||
|
pm2 save
|
||||||
|
|
||||||
|
echo "--- Update Complete ---"
|
||||||
|
echo "Deployed version: $(node -p "require('$APP_DIR/package.json').version")"
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
Loading…
Reference in New Issue
Block a user