games_app/deploy/gitea-stack/set-deploy-secrets.sh
Your Name 07ccda0349
Some checks failed
CI / test-and-build (push) Failing after 1m40s
Fix Gitea Actions registry access and runner config
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-17 20:03:55 +02:00

28 lines
915 B
Bash

#!/usr/bin/env bash
# Create repo Actions secrets DEPLOY_SSH_KEY and DEPLOY_SSH_HOST via Gitea API.
set -euo pipefail
cd ~/gitea
set -a; source .env; set +a
BASE="http://127.0.0.1:${GITEA_HTTP_PORT:-3000}"
USER="${GITEA_ADMIN_USER}"
PASS="${GITEA_ADMIN_PASSWORD}"
OWNER="tloto-admin"
REPO="games_app"
KEY="$(cat /home/deploy/gitea-deploy-ssh/id_ed25519)"
HOST="172.16.0.1"
put_secret() {
local name="$1" value="$2"
# Gitea Actions secrets API (1.19+)
code="$(curl -s -o /tmp/gitea-secret.json -w '%{http_code}' -u "${USER}:${PASS}" \
-X PUT -H 'Content-Type: application/json' \
-d "$(python3 -c 'import json,sys; print(json.dumps({"data":sys.argv[1]}))' "$value")" \
"${BASE}/api/v1/repos/${OWNER}/${REPO}/actions/secrets/${name}")"
echo "secret ${name}: HTTP ${code}"
cat /tmp/gitea-secret.json; echo
}
put_secret DEPLOY_SSH_KEY "$KEY"
put_secret DEPLOY_SSH_HOST "$HOST"
echo "SECRETS_OK"