diff --git a/.gitea/workflows/agent.yml b/.gitea/workflows/agent.yml index 9af7385..777c142 100644 --- a/.gitea/workflows/agent.yml +++ b/.gitea/workflows/agent.yml @@ -130,6 +130,39 @@ jobs: }' > ~/.config/opencode/opencode.json echo "opencode config (secrets masked):"; cat ~/.config/opencode/opencode.json + - name: Set up read-only SSH alias `node1` (swarm diagnostics) + # Writes the deploy key + an SSH config alias so the agent can run + # `ssh node1 ` (matches the homelab opencode.json allowlist). + # No-ops cleanly when the swarm secrets are absent — this shared workflow + # runs in repos that don't have SWARM_HOST/SWARM_USER/SSH_PRIV_KEY, and + # must not fail there. Secrets are passed via env (never inlined in shell). + env: + SWARM_HOST: ${{ secrets.SWARM_HOST }} + SWARM_USER: ${{ secrets.SWARM_USER }} + SSH_PRIV_KEY: ${{ secrets.SSH_PRIV_KEY }} + run: | + if [ -z "$SWARM_HOST" ] || [ -z "$SWARM_USER" ] || [ -z "$SSH_PRIV_KEY" ]; then + echo "swarm secrets not set in this repo — skipping node1 SSH alias" + exit 0 + fi + mkdir -p ~/.ssh && chmod 700 ~/.ssh + # Write the private key with 600 perms; never echo its contents. + printf '%s\n' "$SSH_PRIV_KEY" > ~/.ssh/agent_node1 + chmod 600 ~/.ssh/agent_node1 + # SSH config alias `node1` — last-match-wins in the homelab opencode allowlist + # (`deny ssh *` + specific `allow ssh node1 …`), so the alias name is fixed. + cat > ~/.ssh/config <