mirror of
https://github.com/pezkuwichain/pezkuwi-subquery.git
synced 2026-10-20 18:56:24 +00:00
deploy-vps reached subquery1 as root, through appleboy/ssh-action referenced by tag, with a key whose comment (mamostehp@MamostePC) made it look like a person's. It now uses plain ssh with SUBQUERY_DEPLOY_KEY, which the host pins (authorized_keys restrict,command=) to ops/host/subquery-deploy-ssh: the commit SHA is its only input. subquery-deploy, run through sudo, does what the workflow's script did, with three changes: - It deploys exactly the SHA CI was triggered for, and only a commit on main. - The host's local edits to tracked files (the indexer manifests) are put back whether the deploy succeeds or fails. Before, a failed build exited before `stash pop` and left them stashed. - Only tracked files are stashed. Stashing untracked ones too (.yarn/, which yarn install recreates) made every pop fail half-way; that is how 13 stash entries piled up on the host. test-deploy.sh covers this against a scratch clone (red with the restore trap removed); CI runs it with shellcheck. subquery1's host key is pinned. The indexer endpoints themselves are unchanged. Actions pinned to SHAs; the secret scanner's own AGPL licence is allowed in dependency review.
19 lines
603 B
Bash
Executable File
19 lines
603 B
Bash
Executable File
#!/bin/bash
|
|
# Forced command for the subquery deploy key, installed root-owned at
|
|
# /usr/local/sbin/subquery-deploy-ssh:
|
|
#
|
|
# restrict,command="/usr/local/sbin/subquery-deploy-ssh" ssh-ed25519 ...
|
|
#
|
|
# CI runs `ssh subquery-deploy@<host> <commit sha>`. The SHA is the only
|
|
# input; subquery-deploy, which sudo lets this user run and nothing else,
|
|
# does the work.
|
|
set -euo pipefail
|
|
|
|
SHA="${SSH_ORIGINAL_COMMAND:-}"
|
|
if ! [[ "$SHA" =~ ^[0-9a-f]{40}$ ]]; then
|
|
echo "subquery-deploy-ssh: expected the 40-character commit SHA to deploy" >&2
|
|
exit 2
|
|
fi
|
|
|
|
exec sudo -n /usr/local/sbin/subquery-deploy "$SHA"
|