From 4f6b49918b65b126baeab43fbc9db4d9959866cc Mon Sep 17 00:00:00 2001 From: unimatrixgit <95320811+unimatrixgit@users.noreply.github.com> Date: Sun, 29 Nov 2026 02:30:37 +0100 Subject: [PATCH] Keep deployment entry points and workflow in portable LF format --- .forgejo/workflows/web-deploy.yml | 186 +++++++++++++++--------------- .gitattributes | 4 + website/ops/README.md | 96 +++++++-------- 3 files changed, 145 insertions(+), 141 deletions(-) diff --git a/.forgejo/workflows/web-deploy.yml b/.forgejo/workflows/web-deploy.yml index 87dc7fdc..cd75e390 100644 --- a/.forgejo/workflows/web-deploy.yml +++ b/.forgejo/workflows/web-deploy.yml @@ -1,93 +1,93 @@ -name: DuneRealms Web CI - -on: - push: - branches: - - main - paths: - - 'website/**' - - '.forgejo/workflows/web-deploy.yml' - - '.forgejo/tests/web-deploy.test.mjs' - workflow_dispatch: - -jobs: - web: - if: github.repository == 'unimatrix/web' || (github.repository == 'dev/MC' && github.event_name == 'workflow_dispatch') - runs-on: dune-ci - steps: - - name: Check out exact revision - shell: bash - env: - REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - set -euo pipefail - 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 checkout --detach FETCH_HEAD - test "$(git rev-parse HEAD)" = "$GITHUB_SHA" - - - name: Install Node 22 - uses: actions/setup-node@v4 - with: - node-version: '22' - - - name: Prepare publication comparison - if: github.repository == 'unimatrix/web' && github.ref == 'refs/heads/main' - shell: bash - env: - REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} - 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||"");') - 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" - BEFORE=$(git rev-parse HEAD^) - 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" - fi - node website/scripts/publication-changes.mjs "$BEFORE" "$GITHUB_SHA" - - - name: Verify deployment policy - 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 - run: | - corepack enable - corepack pnpm install --frozen-lockfile - 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 - with: - name: DuneRealms-Website - path: website/dist/ - if-no-files-found: error - retention-days: 1 - - - name: Trigger deployment after successful CI - if: github.repository == 'unimatrix/web' && github.ref == 'refs/heads/main' - shell: bash - env: - DEPLOY_KEY: ${{ secrets.DUNEREALMS_DEPLOY_KEY }} - run: | - install -m 700 -d ~/.ssh - printf '%s\n' "$DEPLOY_KEY" > ~/.ssh/deploy_key - chmod 600 ~/.ssh/deploy_key - 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 - 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 - +name: DuneRealms Web CI + +on: + push: + branches: + - main + paths: + - 'website/**' + - '.forgejo/workflows/web-deploy.yml' + - '.forgejo/tests/web-deploy.test.mjs' + workflow_dispatch: + +jobs: + web: + if: github.repository == 'unimatrix/web' || (github.repository == 'dev/MC' && github.event_name == 'workflow_dispatch') + runs-on: dune-ci + steps: + - name: Check out exact revision + shell: bash + env: + REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -euo pipefail + 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 checkout --detach FETCH_HEAD + test "$(git rev-parse HEAD)" = "$GITHUB_SHA" + + - name: Install Node 22 + uses: actions/setup-node@v4 + with: + node-version: '22' + + - name: Prepare publication comparison + if: github.repository == 'unimatrix/web' && github.ref == 'refs/heads/main' + shell: bash + env: + REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} + 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||"");') + 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" + BEFORE=$(git rev-parse HEAD^) + 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" + fi + node website/scripts/publication-changes.mjs "$BEFORE" "$GITHUB_SHA" + + - name: Verify deployment policy + 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 + run: | + corepack enable + corepack pnpm install --frozen-lockfile + 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 + with: + name: DuneRealms-Website + path: website/dist/ + if-no-files-found: error + retention-days: 1 + + - name: Trigger deployment after successful CI + if: github.repository == 'unimatrix/web' && github.ref == 'refs/heads/main' + shell: bash + env: + DEPLOY_KEY: ${{ secrets.DUNEREALMS_DEPLOY_KEY }} + run: | + install -m 700 -d ~/.ssh + printf '%s\n' "$DEPLOY_KEY" > ~/.ssh/deploy_key + chmod 600 ~/.ssh/deploy_key + 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 + 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 + diff --git a/.gitattributes b/.gitattributes index b26e6b46..cb3ec7e1 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,7 @@ *.pdf binary *.png 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 diff --git a/website/ops/README.md b/website/ops/README.md index 0221565f..64c7ab32 100644 --- a/website/ops/README.md +++ b/website/ops/README.md @@ -1,50 +1,50 @@ -# 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 -rejects commits that do not match the current main branch. - -Forgejo, repositories, artifact storage, the rootless runner, container data, -build workspaces and deployment state use `/mnt/HC_Volume_107481500/dunegit`. -Compatibility links preserve the existing application and home-directory paths. -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. - -`promote-safe-v3.py` is installed as -`/usr/local/sbin/dunerealms-promote-safe-v3`. It prepares an immutable release, -checks a candidate website and panel, updates their shared nginx configuration, -checks public readiness, and restores the previous routing if that check fails. -Retired background workers are stopped and the active process list is saved. - -The first successful promotion retires the migrated baseline systemd website -services. Subsequent candidates are supervised by `dunerealms-runtime.service`. -The separate Forgejo service remains `dunegit.service`. - -Run the promoter routing checks with: - -```sh -python3 -m unittest discover -s website/ops -p 'test_*.py' -``` +# 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 +rejects commits that do not match the current main branch. + +Forgejo, repositories, artifact storage, the rootless runner, container data, +build workspaces and deployment state use `/mnt/HC_Volume_107481500/dunegit`. +Compatibility links preserve the existing application and home-directory paths. +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. + +`promote-safe-v3.py` is installed as +`/usr/local/sbin/dunerealms-promote-safe-v3`. It prepares an immutable release, +checks a candidate website and panel, updates their shared nginx configuration, +checks public readiness, and restores the previous routing if that check fails. +Retired background workers are stopped and the active process list is saved. + +The first successful promotion retires the migrated baseline systemd website +services. Subsequent candidates are supervised by `dunerealms-runtime.service`. +The separate Forgejo service remains `dunegit.service`. + +Run the promoter routing checks with: + +```sh +python3 -m unittest discover -s website/ops -p 'test_*.py' +``` ## 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 increase free disk space. Deployed application releases and their rollback retention are separate from CI artifact retention. No backups or Git history -are removed by this policy. +are removed by this policy.