mirror of
https://github.com/NoeFabris/opencode-antigravity-auth.git
synced 2026-05-13 15:46:05 +00:00
feat(ci): add scripts for setting up self-hosted raspberry pi runner
This commit is contained in:
48
scripts/README-PI.md
Normal file
48
scripts/README-PI.md
Normal file
@@ -0,0 +1,48 @@
|
||||
# Raspberry Pi Runner Setup
|
||||
|
||||
Use your Raspberry Pi as a persistent, self-hosted runner for Opencode Triage. This enables the use of `gh copilot` and other tools without re-authenticating on every run.
|
||||
|
||||
## Prerequisites
|
||||
- A Raspberry Pi (3, 4, or 5) running Raspberry Pi OS (64-bit recommended) or Ubuntu.
|
||||
- Internet connection.
|
||||
- SSH access.
|
||||
|
||||
## Step 1: Get your Token
|
||||
1. Go to your GitHub Repository.
|
||||
2. Navigate to **Settings** > **Actions** > **Runners**.
|
||||
3. Click **New self-hosted runner**.
|
||||
4. Select **Linux** and **ARM64**.
|
||||
5. Copy the **Token** shown in the "Configure" section (you'll need it in Step 2).
|
||||
|
||||
## Step 2: Run the Setup Script
|
||||
Copy the `scripts/` folder to your Pi (or just copy-paste the content).
|
||||
|
||||
```bash
|
||||
# On your Pi
|
||||
mkdir -p ~/opencode-setup
|
||||
cd ~/opencode-setup
|
||||
# (Copy scripts/setup-pi-runner.sh here)
|
||||
chmod +x setup-pi-runner.sh
|
||||
./setup-pi-runner.sh
|
||||
```
|
||||
|
||||
Follow the prompts to enter your Repo URL and Token.
|
||||
|
||||
## Step 3: Authenticate Tools
|
||||
To enable `gh copilot` and other AI tools, run the auth helper:
|
||||
|
||||
```bash
|
||||
# (Copy scripts/auth-pi-tools.sh here)
|
||||
chmod +x auth-pi-tools.sh
|
||||
./auth-pi-tools.sh
|
||||
```
|
||||
Follow the interactive login flows.
|
||||
|
||||
## Step 4: Update Workflow
|
||||
Once your runner is "Idle" (green) in GitHub Settings, update your `.github/workflows/issue-triage.yml`:
|
||||
|
||||
```yaml
|
||||
runs-on: self-hosted
|
||||
# or specifically:
|
||||
# runs-on: [self-hosted, pi]
|
||||
```
|
||||
37
scripts/auth-pi-tools.sh
Executable file
37
scripts/auth-pi-tools.sh
Executable file
@@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Colors
|
||||
GREEN='\033[0;32m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m'
|
||||
|
||||
echo -e "${BLUE}=== Authenticating Development Tools ===${NC}"
|
||||
echo "This script establishes the persistent sessions for your AI tools."
|
||||
|
||||
# 1. GitHub & Copilot
|
||||
echo -e "${GREEN}[1/2] Authenticating GitHub & Copilot...${NC}"
|
||||
echo "Follow the browser login steps..."
|
||||
gh auth login -h github.com -p https -w
|
||||
|
||||
echo "Installing Copilot extension..."
|
||||
gh extension install github/gh-copilot || true
|
||||
|
||||
echo -e "${BLUE}NOTE: Copilot might require a separate auth step.${NC}"
|
||||
echo "Running a test command. If prompted, please authenticate."
|
||||
gh copilot explain "echo hello" || true
|
||||
|
||||
# 2. Google Cloud (Optional)
|
||||
echo -e "${GREEN}[2/2] Authenticating Google Cloud (Optional)...${NC}"
|
||||
if command -v gcloud &> /dev/null; then
|
||||
gcloud auth login
|
||||
gcloud auth application-default login
|
||||
else
|
||||
echo "gcloud CLI not found. Skipping."
|
||||
echo "To install: curl https://sdk.cloud.google.com | bash"
|
||||
fi
|
||||
|
||||
echo -e "${BLUE}=== Authentication Complete ===${NC}"
|
||||
echo "Your credentials are saved in ~/.config/"
|
||||
echo "The Runner service runs as 'root' or your user depending on setup."
|
||||
echo "Check that the runner user has access to these credentials."
|
||||
81
scripts/setup-pi-runner.sh
Executable file
81
scripts/setup-pi-runner.sh
Executable file
@@ -0,0 +1,81 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Colors for output
|
||||
GREEN='\033[0;32m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
echo -e "${BLUE}=== Opencode Raspberry Pi Runner Setup ===${NC}"
|
||||
|
||||
# 1. System Updates & Dependencies
|
||||
echo -e "${GREEN}[1/5] Installing system dependencies...${NC}"
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y curl jq git libdigest-sha-perl
|
||||
|
||||
# 2. Install Node.js (LTS)
|
||||
echo -e "${GREEN}[2/5] Installing Node.js (LTS)...${NC}"
|
||||
if ! command -v node &> /dev/null; then
|
||||
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
|
||||
sudo apt-get install -y nodejs
|
||||
else
|
||||
echo "Node.js is already installed."
|
||||
fi
|
||||
|
||||
# 3. Install GitHub CLI (gh)
|
||||
echo -e "${GREEN}[3/5] Installing GitHub CLI...${NC}"
|
||||
if ! command -v gh &> /dev/null; then
|
||||
(type -p wget >/dev/null || (sudo apt update && sudo apt-get install wget -y)) \
|
||||
&& sudo mkdir -p -m 755 /etc/apt/keyrings \
|
||||
&& wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
|
||||
&& sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
|
||||
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
|
||||
&& sudo apt update \
|
||||
&& sudo apt install gh -y
|
||||
else
|
||||
echo "GitHub CLI is already installed."
|
||||
fi
|
||||
|
||||
# 4. Setup Actions Runner
|
||||
echo -e "${GREEN}[4/5] Setting up GitHub Actions Runner...${NC}"
|
||||
mkdir -p actions-runner && cd actions-runner
|
||||
|
||||
# Detect architecture
|
||||
ARCH=$(dpkg --print-architecture)
|
||||
if [ "$ARCH" == "arm64" ]; then
|
||||
RUNNER_ARCH="arm64"
|
||||
elif [ "$ARCH" == "armhf" ]; then
|
||||
RUNNER_ARCH="arm"
|
||||
else
|
||||
RUNNER_ARCH="x64"
|
||||
fi
|
||||
|
||||
echo "Detected architecture: $RUNNER_ARCH"
|
||||
|
||||
# Fetch latest runner version
|
||||
LATEST_VERSION=$(curl -s https://api.github.com/repos/actions/runner/releases/latest | jq -r .tag_name | sed 's/v//')
|
||||
echo "Downloading runner version $LATEST_VERSION..."
|
||||
|
||||
curl -o actions-runner-linux-${RUNNER_ARCH}-${LATEST_VERSION}.tar.gz -L https://github.com/actions/runner/releases/download/v${LATEST_VERSION}/actions-runner-linux-${RUNNER_ARCH}-${LATEST_VERSION}.tar.gz
|
||||
|
||||
echo "Extracting..."
|
||||
tar xzf ./actions-runner-linux-${RUNNER_ARCH}-${LATEST_VERSION}.tar.gz
|
||||
|
||||
# 5. Configuration Prompt
|
||||
echo -e "${BLUE}=== Configuration Needed ===${NC}"
|
||||
echo "You need your Runner Token from GitHub."
|
||||
echo "Go to: Settings > Actions > Runners > New self-hosted runner"
|
||||
echo "Enter your Repo URL and Token below."
|
||||
|
||||
read -p "Repository URL (e.g., https://github.com/user/repo): " REPO_URL
|
||||
read -p "Runner Token: " RUNNER_TOKEN
|
||||
|
||||
echo -e "${GREEN}Configuring runner...${NC}"
|
||||
./config.sh --url "$REPO_URL" --token "$RUNNER_TOKEN" --name "pi-triage-runner" --work "_work" --labels "self-hosted,pi" --unattended --replace
|
||||
|
||||
echo -e "${GREEN}Installing service...${NC}"
|
||||
sudo ./svc.sh install
|
||||
sudo ./svc.sh start
|
||||
|
||||
echo -e "${BLUE}=== Setup Complete! ===${NC}"
|
||||
echo "Your Pi is now listening for jobs."
|
||||
Reference in New Issue
Block a user