Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

ci: fetch the private editor with a read-only deploy key

esengineeecdce318028
diff --git a/.github/actions/editor-checkout/action.yml b/.github/actions/editor-checkout/action.yml
new file mode 100644
index 000000000..2f9afbc7c
--- /dev/null
+++ b/.github/actions/editor-checkout/action.yml
@@ -0,0 +1,42 @@
+name: Check out the editor submodule
+description: Fetch the private editor at desktop/ with a read-only deploy key.
+
+# The editor is a private repository, so the workflow token cannot read it and
+# `submodules: true` on checkout fails. A deploy key scoped to that one
+# repository is the smallest credential that works: read-only, and useless
+# against anything else if it leaks.
+#
+# Only desktop/ is fetched. `submodules: true` would also pull third_party's ten
+# vendored trees, which no job needing the editor has any use for.
+
+inputs:
+ ssh-key:
+ description: Private half of the estella-editor read-only deploy key.
+ required: true
+
+runs:
+ using: composite
+ steps:
+ - name: Fetch the editor
+ shell: bash
+ env:
+ EDITOR_SSH_KEY: ${{ inputs.ssh-key }}
+ run: |
+ set -euo pipefail
+ if [ -z "${EDITOR_SSH_KEY}" ]; then
+ echo "::error::EDITOR_SSH_KEY is empty. This job drives the editor and has nothing to drive."
+ echo "::error::Set the EDITOR_SSH_KEY secret to the private half of estella-editor's deploy key."
+ exit 1
+ fi
+ mkdir -p ~/.ssh
+ printf '%s\n' "${EDITOR_SSH_KEY}" > ~/.ssh/estella_editor
+ chmod 600 ~/.ssh/estella_editor
+ # Pin the host key rather than accepting whatever answers: this runs on
+ # a fresh runner every time, where trust-on-first-use trusts anything.
+ ssh-keyscan -t ed25519 github.com >> ~/.ssh/known_hosts 2>/dev/null
+ git config --global core.sshCommand 'ssh -i ~/.ssh/estella_editor -o IdentitiesOnly=yes'
+ # .gitmodules names the https URL so a developer with account access can
+ # clone it without a key; the deploy key is SSH-only, hence the rewrite.
+ git config --global url."[email protected]:esengine/estella-editor".insteadOf "https://github.com/esengine/estella-editor"
+ git submodule update --init --depth 1 desktop
+ test -f desktop/package.json
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 77724225b..37460a7bb 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -328,13 +328,13 @@ jobs:
timeout-minutes: 30
steps:
- # The editor is a PRIVATE submodule, so the default token cannot read it.
- # Without EDITOR_SUBMODULE_TOKEN this job fails at checkout — which is the
- # honest outcome: it has nothing to check, and a green tick would say it did.
- uses: actions/checkout@v7
+
+ # The editor is private; without its key this job fails here rather than
+ # reporting green about a checkout it never had.
+ - uses: ./.github/actions/editor-checkout
with:
- submodules: true
- token: ${{ secrets.EDITOR_SUBMODULE_TOKEN || secrets.GITHUB_TOKEN }}
+ ssh-key: ${{ secrets.EDITOR_SSH_KEY }}
- uses: ./.github/actions/setup
@@ -375,10 +375,11 @@ jobs:
# …), which a shallow checkout has none of — the step failed on every run
# that ever reached it.
fetch-depth: 0
- # The comparison frame is the EDITOR's, so this job needs its checkout —
- # and it is a private submodule, so it needs a token that can read one.
- submodules: true
- token: ${{ secrets.EDITOR_SUBMODULE_TOKEN || secrets.GITHUB_TOKEN }}
+
+ # The comparison frame is the EDITOR's, so this job needs its checkout.
+ - uses: ./.github/actions/editor-checkout
+ with:
+ ssh-key: ${{ secrets.EDITOR_SSH_KEY }}
- uses: ./.github/actions/setup
diff --git a/.github/workflows/release-desktop.yml b/.github/workflows/release-desktop.yml
index 20fc0630b..9628394bc 100644
--- a/.github/workflows/release-desktop.yml
+++ b/.github/workflows/release-desktop.yml
@@ -345,17 +345,13 @@ jobs:
contents: write
steps:
- # The editor is a private submodule, so this needs a token that can read it.
- # EDITOR_SUBMODULE_TOKEN is the one; without it the job fails at checkout
- # rather than publishing an installer built from whatever was left behind.
- uses: actions/checkout@v7
- with:
- submodules: false
- token: ${{ secrets.EDITOR_SUBMODULE_TOKEN || secrets.GITHUB_TOKEN }}
- - name: Check out the editor
- shell: bash
- run: git submodule update --init --depth 1 desktop
+ # The editor is private. Without its key this job fails here rather than
+ # publishing an installer built from whatever was left behind.
+ - uses: ./.github/actions/editor-checkout
+ with:
+ ssh-key: ${{ secrets.EDITOR_SSH_KEY }}
- uses: ./.github/actions/setup