Files
CASAN/scripts/setup-ci-runner.sh
T
thanhnvandClaude Opus 4.8 36a4812ef3 refactor(structure): promote app to repo root + remove redundant workspace cruft
Standard production layout: the OKR app (was nested under AINative_OKR_CASAN5/) is now
the repository root. No more wrapper directory.

- Promote AINative_OKR_CASAN5/* -> repo root (backend/ frontend/ packages/ apps/
  .specify/ docs/ infra/ nginx/ scripts/ + configs). Merge tool dirs: .gitea (kept the
  active deploy ci.yml, added harness-ci.yml + runbooks), .claude (agents/commands +
  launch.json), .github moved up.
- Remove redundant: 00_SUBMISSION_PACKAGE, scattered root notes (FPT_CASAN_Full.md,
  tu-tuong-casan.md, casan-tu-sinh..., casan_harness_assessment.md, source-review...,
  README_CASAN5_REFINED.md), casan-next-plans/ and optimize-docs/ (competition/planning
  artifacts — roadmap + design history preserved in git log / commit messages).
- Update all references to the old layout:
  - .gitea/workflows/{ci,harness-ci}.yml, .github/workflows/{ci,deploy}.yml:
    working-directory .; drop AINative_OKR_CASAN5/ prefix; .specify/{tests,scripts}
    -> packages/casan-harness/... (.specify/logs state kept)
  - .claude/launch.json, .gitea/*-runbook.md: path prefixes
  - CLAUDE.md, README.md: docs/input -> apps/okr/domain/input
  - policy-bundle.yaml: 8 policy paths -> packages/casan-harness/...; manifest re-signed
- secrets-scan.sh: fixture excludes -> new package/domain paths.

Full gate from the new root: PASS=64 FAIL=0 SKIP=3.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 13:26:36 +09:00

94 lines
2.6 KiB
Bash

#!/usr/bin/env bash
# Setup act_runner on the CI runner VPS (161.33.149.243).
#
# Prerequisites (run on CI runner VPS as ubuntu):
# 1. Get a runner registration token from Gitea:
# http://161.33.139.73:3000 → Site Administration → Runners → "Create Runner"
# 2. Generate a deploy SSH key for accessing the web VPS:
# ssh-keygen -t ed25519 -f /tmp/deploy_key -N ""
# ssh-copy-id -i /tmp/deploy_key.pub ubuntu@161.33.139.73
# Add /tmp/deploy_key (private) as Gitea secret: DEPLOY_SSH_KEY
# rm /tmp/deploy_key
#
# Usage:
# RUNNER_TOKEN=<token-from-gitea> bash setup-ci-runner.sh
#
set -euo pipefail
GITEA_URL="http://161.33.139.73:3000"
RUNNER_NAME="casan-ci-runner"
RUNNER_VERSION="v0.2.12"
INSTALL_DIR="/opt/act-runner"
if [[ -z "${RUNNER_TOKEN:-}" ]]; then
echo "ERROR: RUNNER_TOKEN env var is required."
echo " Get it from: $GITEA_URL → Site Administration → Runners → Create Runner"
exit 1
fi
echo "=== Installing act_runner $RUNNER_VERSION ==="
sudo mkdir -p "$INSTALL_DIR"
sudo curl -fsSL \
"https://gitea.com/gitea/act_runner/releases/download/${RUNNER_VERSION}/act_runner-${RUNNER_VERSION}-linux-amd64" \
-o "$INSTALL_DIR/act_runner"
sudo chmod +x "$INSTALL_DIR/act_runner"
echo "=== Writing runner config ==="
sudo tee "$INSTALL_DIR/config.yaml" > /dev/null <<'CONFIG'
log:
level: info
runner:
name: "casan-ci-runner"
capacity: 1
labels:
- "ci-runner:docker://catthehacker/ubuntu:act-22.04"
fetch_interval: 5s
fetch_timeout: 60s
container:
# host network so the job container can reach Gitea at 161.33.139.73:3000
network: host
# 2 GB RAM available on CI runner — builds need up to 1.5 GB
options: "--memory 1536m --cpus 1.5"
valid_volumes:
- "**"
CONFIG
echo "=== Registering runner with Gitea ==="
cd "$INSTALL_DIR"
sudo ./act_runner register \
--instance "$GITEA_URL" \
--token "$RUNNER_TOKEN" \
--name "$RUNNER_NAME" \
--no-interactive
echo "=== Installing systemd service ==="
sudo tee /etc/systemd/system/act-runner.service > /dev/null <<'SERVICE'
[Unit]
Description=Gitea act_runner (CI builds)
After=docker.service
Requires=docker.service
[Service]
User=ubuntu
Group=docker
WorkingDirectory=/opt/act-runner
ExecStart=/opt/act-runner/act_runner daemon --config /opt/act-runner/config.yaml
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
SERVICE
sudo systemctl daemon-reload
sudo systemctl enable act-runner
sudo systemctl start act-runner
echo ""
echo "=== CI runner setup complete ==="
echo "Check status: sudo systemctl status act-runner"
echo "View logs: sudo journalctl -u act-runner -f"
echo "Verify in Gitea: $GITEA_URL/-/admin/runners"