Build canonical web staging scripts and pin their repository source

This commit is contained in:
unimatrixgit 2026-11-29 02:29:30 +01:00
commit a22648d579
8 changed files with 92 additions and 2 deletions

View file

@ -50,6 +50,7 @@ jobs:
run: |
node --test .forgejo/tests/web-deploy.test.mjs
python3 -m unittest discover -s website/ops -p 'test_*.py'
bash -n website/ops/dunerealms-ci-trigger website/ops/dunerealms-build-release
- name: Build and test website
working-directory: website
@ -59,6 +60,14 @@ jobs:
corepack pnpm build
corepack pnpm test
- name: Upload tested deployment scripts
uses: actions/upload-artifact@v3
with:
name: DuneRealms-Website-Operations
path: website/dist/deployment/
if-no-files-found: error
retention-days: 7
- name: Upload website build
if: github.repository == 'unimatrix/web' && github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v3

View file

@ -161,6 +161,14 @@ that restyle as fulfilment of the replacement requirement.
server failed before returning remote output. No server change occurred;
this is not proof that the game servers are down. Any access/rollout fix
remains coordinator-only and must be codified in the build configuration.
- Follow-up: direct SSH using the existing local private-key store succeeded
for the already registered `dev` account. No key was disclosed or created.
Read-only inspection found the installed staging checkout still fetches
the old combined MC remote and has a divergent worktree HEAD. Do not reset
that worktree. The trigger and builder now pin the canonical web main fetch
in committed source, and the build emits a hashed operational-script package.
Bootstrap installation remains pending until the exact package passes CI;
record its installed hashes when performed. No SSH mutation is claimed yet.
- Existing actual functions, NPC callbacks, JARVIS integration and earned
player progress must survive the interface replacement. Validate mappings,
artifact hashes, installed versions and in-game operation before claiming

View file

@ -1,5 +1,24 @@
# Migrated web deployment
## Canonical website source after the repository split
The trigger and staging builder fetch `refs/heads/main` explicitly from
`https://www.dunerealms.com/git/unimatrix/web.git`. They do not trust the
historical checkout's configured `origin`. The checkout is an object store for
the approved commit: a divergent worktree HEAD must not be reset or copied live.
Both scripts compare the requested commit with the freshly fetched canonical
main before queueing or building it.
The website build packages these two scripts in `dist/deployment`, with a
manifest recording repository, source commit, byte sizes and SHA256 hashes.
CI uploads the tested package as `DuneRealms-Website-Operations`. Any necessary
bootstrap installation must use that exact built package, verify its manifest
and expected tested commit, and install only the two existing script targets:
`/usr/local/bin/dunerealms-ci-trigger` and
`/usr/local/bin/dunerealms-build-release`. Record installed hashes and the CI
reference. Do not install scripts from a dirty worktree or publish handwritten
live fixes. Normal website publication remains main-only through CI.
The production website is hosted at `91.107.196.242`. The Forgejo Actions
workflow pins that host's SSH key and can trigger deployment only from `main`.
Its deploy key is restricted to `/usr/local/bin/dunerealms-ci-trigger`, which

View file

@ -2,13 +2,14 @@
set -Eeuo pipefail
BASE=/home/dunedeploy/ci-deploy
REPO=/home/dunedeploy/web-deployment
SOURCE_URL=https://www.dunerealms.com/git/unimatrix/web.git
# Share the publication mutex; no cleanup command is part of a build.
exec 9< /mnt/HC_Volume_107481500/dunegit/ci/promotion/safe-lock
flock --shared --nonblock 9 || { echo 'Publication mutex busy; build deferred to systemd retry'; exit 75; }
SHA=$(cat "$BASE/pending-commit")
[[ "$SHA" =~ ^[0-9a-f]{40}$ ]] || exit 1
cd "$REPO"
git fetch -q origin main
git fetch -q "$SOURCE_URL" refs/heads/main
MAIN=$(git rev-parse FETCH_HEAD)
[[ "$SHA" == "$MAIN" ]] || { echo 'Not current main'; exit 1; }
DEST="$BASE/artifacts/$SHA"

View file

@ -3,7 +3,8 @@ set -euo pipefail
SHA="${SSH_ORIGINAL_COMMAND:-}"
[[ "$SHA" =~ ^[0-9a-f]{40}$ ]] || { echo "Ongeldige commit"; exit 1; }
REPO=/home/dunedeploy/web-deployment
git -C "$REPO" fetch -q origin main
SOURCE_URL=https://www.dunerealms.com/git/unimatrix/web.git
git -C "$REPO" fetch -q "$SOURCE_URL" refs/heads/main
MAIN=$(git -C "$REPO" rev-parse FETCH_HEAD)
if [ "$SHA" != "$MAIN" ]; then echo "Geweigerd: commit is niet de huidige main"; exit 1; fi
exec 9< /mnt/HC_Volume_107481500/dunegit/ci/promotion/safe-lock

View file

@ -1,4 +1,5 @@
import {recipeCatalogue,recipeIcons} from './recipe-catalogue.mjs';
import {packageDeploymentScripts} from './deployment-package.mjs';
import {applySharedHeader,applySharedFooter,SHARED_FOOTER_SCRIPT,cleanLegacyChromeScript,assertSharedChrome,sharedFooterBrandScript} from './site-chrome.mjs';
import {SHARED_HEADER} from './portal-navigation.mjs';
import {sharedHomepageHeaderScript} from './homepage-header.mjs';
@ -61,6 +62,10 @@ mkdirSync(path.join(dist,'server'),{recursive:true});mkdirSync(path.join(dist,'.
let api=['public-item-metadata.mjs','feed-api.mjs','exchange-api.mjs','forum-api.mjs','community-api.mjs','portal-api.mjs'].map(file=>readFileSync(path.join(root,'worker',file),'utf8').replace(/^import .*;$/gm,'').replace(/export /g,'')).join('\n');let runtime=readFileSync(path.join(root,'worker/runtime.mjs'),'utf8').replace(/^import .*;$/gm,'');
writeFileSync(path.join(dist,'server/index.js'),shardNames.map((name,i)=>'import DATA'+i+' from '+JSON.stringify('./'+name)+';').join('\n')+'\nconst ASSET_DATA=Object.assign({},'+shardNames.map((_,i)=>'DATA'+i).join(',')+');\n'+api+'\n'+runtime);cpSync(path.join(root,'.openai/hosting.json'),path.join(dist,'.openai/hosting.json'));console.log('Built Worker with',assetCount,'embedded website assets');
if(existsSync(path.join(root,'drizzle')))cpSync(path.join(root,'drizzle'),path.join(dist,'.openai/drizzle'),{recursive:true});
// Native applications consume the same compiled chrome as the public Worker.
// Operational fixes travel in the tested artifact rather than as live-only edits.
packageDeploymentScripts(path.join(dist,'deployment'),buildCommit||null);
// Native applications consume the same compiled chrome as the public Worker.
// nginx follows the atomically promoted current release, so no stale host copy
// can retain an old Alpha version, navigation badge or rates page.

View file

@ -0,0 +1,17 @@
import {mkdirSync,readFileSync,writeFileSync} from 'node:fs';
import path from 'node:path';
import {fileURLToPath} from 'node:url';
import {createHash} from 'node:crypto';
export function packageDeploymentScripts(output,sourceCommit=null,{sourceDirectory=fileURLToPath(new URL('../ops/',import.meta.url))}={}){
if(sourceCommit!==null&&!/^[a-f0-9]{40}$/.test(sourceCommit))throw Error('Invalid deployment source commit');
const files={};
for(const name of ['dunerealms-ci-trigger','dunerealms-build-release']){
const bytes=Buffer.from(readFileSync(path.join(sourceDirectory,name),'utf8').replaceAll('\r\n','\n'));
files[name]={sha256:createHash('sha256').update(bytes).digest('hex'),bytes:bytes.length};
mkdirSync(output,{recursive:true});writeFileSync(path.join(output,name),bytes);
}
const manifest={schema:1,sourceRepository:'https://www.dunerealms.com/git/unimatrix/web.git',sourceCommit,files};
writeFileSync(path.join(output,'manifest.json'),JSON.stringify(manifest,null,2)+'\n');
return manifest;
}

View file

@ -0,0 +1,30 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import {mkdtempSync,readFileSync,mkdirSync,writeFileSync} from 'node:fs';
import {tmpdir} from 'node:os';
import path from 'node:path';
import {createHash} from 'node:crypto';
import {packageDeploymentScripts} from '../scripts/deployment-package.mjs';
test('built operational scripts have deterministic bytes, exact hashes and recorded source identity',()=>{
const folder=mkdtempSync(path.join(tmpdir(),'dune-web-deployment-')),source=path.join(folder,'source'),output=path.join(folder,'output');mkdirSync(source);
for(const name of ['dunerealms-ci-trigger','dunerealms-build-release'])writeFileSync(path.join(source,name),'#!/bin/bash\r\necho verified\r\n');
const commit='a'.repeat(40),manifest=packageDeploymentScripts(output,commit,{sourceDirectory:source});
assert.equal(manifest.sourceCommit,commit);assert.equal(manifest.sourceRepository,'https://www.dunerealms.com/git/unimatrix/web.git');
for(const [name,record] of Object.entries(manifest.files)){
const bytes=readFileSync(path.join(output,name));assert.equal(bytes.toString(),'#!/bin/bash\necho verified\n');
assert.equal(record.bytes,bytes.length);assert.equal(record.sha256,createHash('sha256').update(bytes).digest('hex'));
}
assert.deepEqual(JSON.parse(readFileSync(path.join(output,'manifest.json'))),manifest);
assert.throws(()=>packageDeploymentScripts(output,'../main',{sourceDirectory:source}),/Invalid deployment source commit/);
});
test('website trigger and builder fetch only canonical web main even when checkout origin differs',()=>{
for(const name of ['dunerealms-ci-trigger','dunerealms-build-release']){
const source=readFileSync(new URL('../ops/'+name,import.meta.url),'utf8');
assert.match(source,/^SOURCE_URL=https:\/\/www\.dunerealms\.com\/git\/unimatrix\/web\.git\r?$/m);
assert.match(source,/git (?:-C "\$REPO" )?fetch -q "\$SOURCE_URL" refs\/heads\/main/);
assert.doesNotMatch(source,/git .*fetch -q origin/);
assert.match(source,/rev-parse FETCH_HEAD/);
}
});