Keep deployment entry points and workflow in portable LF format

This commit is contained in:
unimatrixgit 2026-11-29 02:30:37 +01:00
commit 4f6b49918b
3 changed files with 145 additions and 141 deletions

View file

@ -1,93 +1,93 @@
name: DuneRealms Web CI name: DuneRealms Web CI
on: on:
push: push:
branches: branches:
- main - main
paths: paths:
- 'website/**' - 'website/**'
- '.forgejo/workflows/web-deploy.yml' - '.forgejo/workflows/web-deploy.yml'
- '.forgejo/tests/web-deploy.test.mjs' - '.forgejo/tests/web-deploy.test.mjs'
workflow_dispatch: workflow_dispatch:
jobs: jobs:
web: web:
if: github.repository == 'unimatrix/web' || (github.repository == 'dev/MC' && github.event_name == 'workflow_dispatch') if: github.repository == 'unimatrix/web' || (github.repository == 'dev/MC' && github.event_name == 'workflow_dispatch')
runs-on: dune-ci runs-on: dune-ci
steps: steps:
- name: Check out exact revision - name: Check out exact revision
shell: bash shell: bash
env: env:
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: | run: |
set -euo pipefail set -euo pipefail
git init . git init .
git -c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$REPO_TOKEN" | base64 -w0)" fetch --depth=1 "https://www.dunerealms.com/git/${GITHUB_REPOSITORY}.git" "$GITHUB_SHA" git -c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$REPO_TOKEN" | base64 -w0)" fetch --depth=1 "https://www.dunerealms.com/git/${GITHUB_REPOSITORY}.git" "$GITHUB_SHA"
git checkout --detach FETCH_HEAD git checkout --detach FETCH_HEAD
test "$(git rev-parse HEAD)" = "$GITHUB_SHA" test "$(git rev-parse HEAD)" = "$GITHUB_SHA"
- name: Install Node 22 - name: Install Node 22
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: '22' node-version: '22'
- name: Prepare publication comparison - name: Prepare publication comparison
if: github.repository == 'unimatrix/web' && github.ref == 'refs/heads/main' if: github.repository == 'unimatrix/web' && github.ref == 'refs/heads/main'
shell: bash shell: bash
env: env:
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: | run: |
BEFORE=$(node -e 'const fs=require("fs");const p=process.env.GITHUB_EVENT_PATH;const e=p&&fs.existsSync(p)?JSON.parse(fs.readFileSync(p)):{};process.stdout.write(e.before||"");') BEFORE=$(node -e 'const fs=require("fs");const p=process.env.GITHUB_EVENT_PATH;const e=p&&fs.existsSync(p)?JSON.parse(fs.readFileSync(p)):{};process.stdout.write(e.before||"");')
if [[ ! "$BEFORE" =~ ^[0-9a-f]{40}$ || "$BEFORE" =~ ^0+$ ]]; then if [[ ! "$BEFORE" =~ ^[0-9a-f]{40}$ || "$BEFORE" =~ ^0+$ ]]; then
git -c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$REPO_TOKEN" | base64 -w0)" fetch --deepen=1 https://www.dunerealms.com/git/unimatrix/web.git "$GITHUB_SHA" git -c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$REPO_TOKEN" | base64 -w0)" fetch --deepen=1 https://www.dunerealms.com/git/unimatrix/web.git "$GITHUB_SHA"
BEFORE=$(git rev-parse HEAD^) BEFORE=$(git rev-parse HEAD^)
else else
git -c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$REPO_TOKEN" | base64 -w0)" fetch --depth=1 https://www.dunerealms.com/git/unimatrix/web.git "$BEFORE" git -c http.extraheader="AUTHORIZATION: basic $(printf 'x-access-token:%s' "$REPO_TOKEN" | base64 -w0)" fetch --depth=1 https://www.dunerealms.com/git/unimatrix/web.git "$BEFORE"
fi fi
node website/scripts/publication-changes.mjs "$BEFORE" "$GITHUB_SHA" node website/scripts/publication-changes.mjs "$BEFORE" "$GITHUB_SHA"
- name: Verify deployment policy - name: Verify deployment policy
run: | run: |
node --test .forgejo/tests/web-deploy.test.mjs node --test .forgejo/tests/web-deploy.test.mjs
python3 -m unittest discover -s website/ops -p 'test_*.py' python3 -m unittest discover -s website/ops -p 'test_*.py'
bash -n website/ops/dunerealms-ci-trigger website/ops/dunerealms-build-release bash -n website/ops/dunerealms-ci-trigger website/ops/dunerealms-build-release
- name: Build and test website - name: Build and test website
working-directory: website working-directory: website
run: | run: |
corepack enable corepack enable
corepack pnpm install --frozen-lockfile corepack pnpm install --frozen-lockfile
corepack pnpm build corepack pnpm build
corepack pnpm test corepack pnpm test
- name: Upload tested deployment scripts - name: Upload tested deployment scripts
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: DuneRealms-Website-Operations name: DuneRealms-Website-Operations
path: website/dist/deployment/ path: website/dist/deployment/
if-no-files-found: error if-no-files-found: error
retention-days: 7 retention-days: 7
- name: Upload website build - name: Upload website build
if: github.repository == 'unimatrix/web' && github.ref == 'refs/heads/main' if: github.repository == 'unimatrix/web' && github.ref == 'refs/heads/main'
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: DuneRealms-Website name: DuneRealms-Website
path: website/dist/ path: website/dist/
if-no-files-found: error if-no-files-found: error
retention-days: 1 retention-days: 1
- name: Trigger deployment after successful CI - name: Trigger deployment after successful CI
if: github.repository == 'unimatrix/web' && github.ref == 'refs/heads/main' if: github.repository == 'unimatrix/web' && github.ref == 'refs/heads/main'
shell: bash shell: bash
env: env:
DEPLOY_KEY: ${{ secrets.DUNEREALMS_DEPLOY_KEY }} DEPLOY_KEY: ${{ secrets.DUNEREALMS_DEPLOY_KEY }}
run: | run: |
install -m 700 -d ~/.ssh install -m 700 -d ~/.ssh
printf '%s\n' "$DEPLOY_KEY" > ~/.ssh/deploy_key printf '%s\n' "$DEPLOY_KEY" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key chmod 600 ~/.ssh/deploy_key
trap 'rm -f ~/.ssh/deploy_key' EXIT trap 'rm -f ~/.ssh/deploy_key' EXIT
printf '%s\n' '91.107.196.242 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIC8x/XocsIz41fWHGty0DbZhSvafSQFt9jaHHgzdr55W root@ubuntu-4gb-fsn1-1' >> ~/.ssh/known_hosts printf '%s\n' '91.107.196.242 ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIC8x/XocsIz41fWHGty0DbZhSvafSQFt9jaHHgzdr55W root@ubuntu-4gb-fsn1-1' >> ~/.ssh/known_hosts
ssh -p 22 -i ~/.ssh/deploy_key -o IdentitiesOnly=yes -o BatchMode=yes -o StrictHostKeyChecking=yes dunedeploy@91.107.196.242 "$GITHUB_SHA" ssh -p 22 -i ~/.ssh/deploy_key -o IdentitiesOnly=yes -o BatchMode=yes -o StrictHostKeyChecking=yes dunedeploy@91.107.196.242 "$GITHUB_SHA"
rm -f ~/.ssh/deploy_key rm -f ~/.ssh/deploy_key

4
.gitattributes vendored
View file

@ -1,3 +1,7 @@
*.pdf binary *.pdf binary
*.png binary *.png binary
*.zip binary *.zip binary
.forgejo/workflows/web-deploy.yml text eol=lf
website/ops/dunerealms-ci-trigger text eol=lf
website/ops/dunerealms-build-release text eol=lf
website/ops/README.md text eol=lf

View file

@ -1,50 +1,50 @@
# Migrated web deployment # Migrated web deployment
## Canonical website source after the repository split ## Canonical website source after the repository split
The trigger and staging builder fetch `refs/heads/main` explicitly from The trigger and staging builder fetch `refs/heads/main` explicitly from
`https://www.dunerealms.com/git/unimatrix/web.git`. They do not trust the `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 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. 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 Both scripts compare the requested commit with the freshly fetched canonical
main before queueing or building it. main before queueing or building it.
The website build packages these two scripts in `dist/deployment`, with a The website build packages these two scripts in `dist/deployment`, with a
manifest recording repository, source commit, byte sizes and SHA256 hashes. manifest recording repository, source commit, byte sizes and SHA256 hashes.
CI uploads the tested package as `DuneRealms-Website-Operations`. Any necessary CI uploads the tested package as `DuneRealms-Website-Operations`. Any necessary
bootstrap installation must use that exact built package, verify its manifest bootstrap installation must use that exact built package, verify its manifest
and expected tested commit, and install only the two existing script targets: and expected tested commit, and install only the two existing script targets:
`/usr/local/bin/dunerealms-ci-trigger` and `/usr/local/bin/dunerealms-ci-trigger` and
`/usr/local/bin/dunerealms-build-release`. Record installed hashes and the CI `/usr/local/bin/dunerealms-build-release`. Record installed hashes and the CI
reference. Do not install scripts from a dirty worktree or publish handwritten reference. Do not install scripts from a dirty worktree or publish handwritten
live fixes. Normal website publication remains main-only through CI. live fixes. Normal website publication remains main-only through CI.
The production website is hosted at `91.107.196.242`. The Forgejo Actions 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`. 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 Its deploy key is restricted to `/usr/local/bin/dunerealms-ci-trigger`, which
rejects commits that do not match the current main branch. rejects commits that do not match the current main branch.
Forgejo, repositories, artifact storage, the rootless runner, container data, Forgejo, repositories, artifact storage, the rootless runner, container data,
build workspaces and deployment state use `/mnt/HC_Volume_107481500/dunegit`. build workspaces and deployment state use `/mnt/HC_Volume_107481500/dunegit`.
Compatibility links preserve the existing application and home-directory paths. Compatibility links preserve the existing application and home-directory paths.
The volume is part of the live service and must remain attached. The services The volume is part of the live service and must remain attached. The services
require its mount before starting, rather than writing to an empty mountpoint. require its mount before starting, rather than writing to an empty mountpoint.
`promote-safe-v3.py` is installed as `promote-safe-v3.py` is installed as
`/usr/local/sbin/dunerealms-promote-safe-v3`. It prepares an immutable release, `/usr/local/sbin/dunerealms-promote-safe-v3`. It prepares an immutable release,
checks a candidate website and panel, updates their shared nginx configuration, checks a candidate website and panel, updates their shared nginx configuration,
checks public readiness, and restores the previous routing if that check fails. checks public readiness, and restores the previous routing if that check fails.
Retired background workers are stopped and the active process list is saved. Retired background workers are stopped and the active process list is saved.
The first successful promotion retires the migrated baseline systemd website The first successful promotion retires the migrated baseline systemd website
services. Subsequent candidates are supervised by `dunerealms-runtime.service`. services. Subsequent candidates are supervised by `dunerealms-runtime.service`.
The separate Forgejo service remains `dunegit.service`. The separate Forgejo service remains `dunegit.service`.
Run the promoter routing checks with: Run the promoter routing checks with:
```sh ```sh
python3 -m unittest discover -s website/ops -p 'test_*.py' python3 -m unittest discover -s website/ops -p 'test_*.py'
``` ```
## CI artifact retention ## CI artifact retention
@ -62,4 +62,4 @@ Forgejo removes the corresponding physical chunks through its existing
`cleanup_actions` maintenance task; deleting API records need not immediately `cleanup_actions` maintenance task; deleting API records need not immediately
increase free disk space. Deployed application releases and their rollback increase free disk space. Deployed application releases and their rollback
retention are separate from CI artifact retention. No backups or Git history retention are separate from CI artifact retention. No backups or Git history
are removed by this policy. are removed by this policy.