Skip to content

Commit f6a9aa6

Browse files
committed
refactor: activate once in a temporary container, then reuse the license in the long-running container
Now we got the license secret to be read, we got this error: "Machine bindings don't match". So it seems that the license I generated locally can't be used. So we need to activate the license within the container
1 parent a9f4c02 commit f6a9aa6

File tree

1 file changed

+48
-24
lines changed

1 file changed

+48
-24
lines changed

.github/workflows/claude-nl-suite.yml

Lines changed: 48 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ jobs:
8383
mkdir -p "$RUNNER_TEMP/unity-status"
8484
rm -f "$RUNNER_TEMP/unity-status"/unity-mcp-status-*.json || true
8585
86-
# ---------- Start headless Unity with MCP bridge ----------
87-
- name: Start Unity MCP bridge in background
86+
# ---------- Activate Unity using game-ci's activation scripts ----------
87+
- name: Activate Unity license in temporary container
8888
if: steps.detect.outputs.unity_ok == 'true'
8989
shell: bash
9090
env:
@@ -95,39 +95,63 @@ jobs:
9595
run: |
9696
set -euxo pipefail
9797
98-
# Use the unityci/editor image's built-in activation via entrypoint
99-
# Create activation wrapper script that runs activation then starts Unity with MCP
100-
docker rm -f unity-mcp >/dev/null 2>&1 || true
98+
# Create directories for license persistence
99+
mkdir -p "$RUNNER_TEMP/unity-license"
101100
102-
# The unityci image uses /usr/bin/activate.sh for license setup
103-
# We'll call it first, then start Unity with our MCP bridge
104-
docker run -d --name unity-mcp --network host \
101+
# Run game-ci's activation in a temporary container
102+
# This uses their built-in /steps/activate.sh script
103+
docker run --rm \
105104
-e UNITY_EMAIL \
106105
-e UNITY_PASSWORD \
107106
-e UNITY_LICENSE \
108107
-e UNITY_SERIAL \
108+
-v "$RUNNER_TEMP/unity-license:/root/.local/share/unity3d" \
109+
${{ env.UNITY_IMAGE }} \
110+
bash -c '
111+
# game-ci images have activation scripts at /steps/
112+
if [ -f /steps/activate.sh ]; then
113+
bash /steps/activate.sh
114+
else
115+
# Fallback: manual activation
116+
if [[ -n "${UNITY_LICENSE:-}" ]]; then
117+
mkdir -p /root/.local/share/unity3d/Unity
118+
echo "$UNITY_LICENSE" | base64 -d > /root/.local/share/unity3d/Unity/Unity_lic.ulf 2>/dev/null || \
119+
echo "$UNITY_LICENSE" > /root/.local/share/unity3d/Unity/Unity_lic.ulf
120+
elif [[ -n "${UNITY_EMAIL:-}" && -n "${UNITY_PASSWORD:-}" ]]; then
121+
/opt/unity/Editor/Unity -quit -batchmode -nographics -logFile - \
122+
-username "$UNITY_EMAIL" -password "$UNITY_PASSWORD" ${UNITY_SERIAL:+-serial "$UNITY_SERIAL"}
123+
fi
124+
fi
125+
echo "License files:"
126+
find /root/.local/share/unity3d -type f -ls || true
127+
'
128+
129+
# Verify license was created
130+
echo "Checking for license files on host:"
131+
find "$RUNNER_TEMP/unity-license" -type f || echo "No license files found!"
132+
133+
# ---------- Start Unity with MCP bridge ----------
134+
- name: Start Unity MCP bridge in background
135+
if: steps.detect.outputs.unity_ok == 'true'
136+
shell: bash
137+
run: |
138+
set -euxo pipefail
139+
140+
docker rm -f unity-mcp >/dev/null 2>&1 || true
141+
142+
# Start Unity with the pre-activated license mounted
143+
docker run -d --name unity-mcp --network host \
109144
-e UNITY_MCP_ALLOW_BATCH=1 \
110145
-e UNITY_MCP_STATUS_DIR=/root/.unity-mcp \
111146
-e UNITY_MCP_BIND_HOST=127.0.0.1 \
112147
-v "${{ github.workspace }}:/workspace" -w /workspace \
113148
-v "$RUNNER_TEMP/unity-status:/root/.unity-mcp" \
149+
-v "$RUNNER_TEMP/unity-license:/root/.local/share/unity3d" \
114150
${{ env.UNITY_IMAGE }} \
115-
bash -c '
116-
# Activate Unity license (unityci pattern)
117-
if [[ -n "${UNITY_LICENSE:-}" ]]; then
118-
mkdir -p /root/.local/share/unity3d/Unity
119-
# Try base64 decode, fallback to plain text
120-
echo "$UNITY_LICENSE" | base64 -d > /root/.local/share/unity3d/Unity/Unity_lic.ulf 2>/dev/null || \
121-
echo "$UNITY_LICENSE" > /root/.local/share/unity3d/Unity/Unity_lic.ulf
122-
chmod 600 /root/.local/share/unity3d/Unity/Unity_lic.ulf
123-
fi
124-
125-
# Start Unity with MCP bridge
126-
/opt/unity/Editor/Unity -batchmode -nographics -logFile - \
127-
-stackTraceLogType Full \
128-
-projectPath /workspace/TestProjects/UnityMCPTests \
129-
-executeMethod MCPForUnity.Editor.MCPForUnityBridge.StartAutoConnect
130-
'
151+
/opt/unity/Editor/Unity -batchmode -nographics -logFile - \
152+
-stackTraceLogType Full \
153+
-projectPath /workspace/TestProjects/UnityMCPTests \
154+
-executeMethod MCPForUnity.Editor.MCPForUnityBridge.StartAutoConnect
131155
132156
# ---------- Wait for Unity bridge ----------
133157
- name: Wait for Unity bridge (robust)

0 commit comments

Comments
 (0)