From 7473706d5176d0acf4194dd11810e48edd2a5e48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20M=C3=A9ndez=20Rey?= Date: Sun, 27 Sep 2026 08:43:23 +0200 Subject: [PATCH 1/3] Create static.yml --- .github/workflows/static.yml | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/static.yml diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml new file mode 100644 index 0000000..e34c500 --- /dev/null +++ b/.github/workflows/static.yml @@ -0,0 +1,43 @@ +# Simple workflow for deploying static content to GitHub Pages +name: Deploy static content to Pages + +on: + # Runs on pushes targeting the default branch + push: + branches: ["master"] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + # Single deploy job since we're just deploying + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Pages + uses: actions/configure-pages@v5 + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + # Upload entire repository + path: '.' + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v5 From 6bfd4a87947f54ac5b50839cda3427db543f06f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20M=C3=A9ndez=20Rey?= Date: Sun, 27 Sep 2026 06:46:24 +0000 Subject: [PATCH 2/3] Publish only web/ to GitHub Pages, pointing at the game server The workflow uploaded the whole repository, so the site root had no index.html and the scripts, Docker files and world data were published as web pages. Build the site from web/ instead, leave out the game page (the terminal only works on the game server) and write config.js with the game server URL from the CONQUER_SERVER_URL repository variable, so Play now and the live game status point there. Deploy only when the website changes. --- .github/workflows/static.yml | 73 +++++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 21 deletions(-) diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index e34c500..ae3ce85 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -1,43 +1,74 @@ -# Simple workflow for deploying static content to GitHub Pages -name: Deploy static content to Pages +# SPDX-FileCopyrightText: 2025 Juan Manuel Méndez Rey +# SPDX-License-Identifier: GPL-3.0-or-later +# +# Publish the public website (landing page, player's guide, tutorial) to +# GitHub Pages. Only web/ is published, never the rest of the repository. +# +# The game itself (terminal, accounts, turns) runs on the game server. Set +# the repository variable CONQUER_SERVER_URL (Settings > Secrets and +# variables > Actions > Variables), e.g. https://conquer.example.org, so +# "Play now" opens the game there and the live game status is read from it. +# Enable Pages with Settings > Pages > Source: GitHub Actions. +name: Deploy the website to GitHub Pages on: - # Runs on pushes targeting the default branch push: - branches: ["master"] - - # Allows you to run this workflow manually from the Actions tab + branches: [master] + paths: + - "web/**" + - ".github/workflows/static.yml" workflow_dispatch: -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages permissions: contents: read pages: write id-token: write -# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. -# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +# One deployment at a time; never cancel a deployment in progress concurrency: - group: "pages" + group: pages cancel-in-progress: false jobs: - # Single deploy job since we're just deploying + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + + - uses: actions/configure-pages@v5 + + - name: Build the site from web/ + env: + CONQUER_SERVER_URL: ${{ vars.CONQUER_SERVER_URL }} + run: | + if [ ! -f web/index.html ]; then + echo "web/index.html not found: nothing to publish" >&2 + exit 1 + fi + rm -rf _site + cp -r web _site + # The game terminal only works on the game server (it embeds /play/) + rm -f _site/game.html + # Where the game server lives (empty: the site shows no live status) + server="${CONQUER_SERVER_URL%/}" + printf 'window.CONQUER_CONFIG = { server: %s };\n' \ + "$(jq -Rn --arg s "$server" '$s')" > _site/config.js + # Serve files as they are (no Jekyll processing) + touch _site/.nojekyll + echo "Game server: ${server:-(not set)}" + ls -la _site + + - uses: actions/upload-pages-artifact@v3 + with: + path: _site + deploy: + needs: build + runs-on: ubuntu-latest environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup Pages - uses: actions/configure-pages@v5 - - name: Upload artifact - uses: actions/upload-pages-artifact@v3 - with: - # Upload entire repository - path: '.' - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v5 From 299b0c1f94399b2fb20d095aa29453feb54a479d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20M=C3=A9ndez=20Rey?= Date: Sun, 27 Sep 2026 07:19:46 +0000 Subject: [PATCH 3/3] Write the game server setting as server.js The VPS vhost refuses any path containing "config", so config.js could not load from the game server; the site now reads server.js. --- .github/workflows/static.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index ae3ce85..8373c3b 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -49,10 +49,11 @@ jobs: cp -r web _site # The game terminal only works on the game server (it embeds /play/) rm -f _site/game.html - # Where the game server lives (empty: the site shows no live status) + # Where the game server lives (empty: the site shows no live status). + # Named server.js: the VPS vhost refuses paths containing "config" server="${CONQUER_SERVER_URL%/}" printf 'window.CONQUER_CONFIG = { server: %s };\n' \ - "$(jq -Rn --arg s "$server" '$s')" > _site/config.js + "$(jq -Rn --arg s "$server" '$s')" > _site/server.js # Serve files as they are (no Jekyll processing) touch _site/.nojekyll echo "Game server: ${server:-(not set)}"