Install Forgejo runner and config to better location
Some checks are pending
Some checks are pending
This commit is contained in:
parent
a4cb106738
commit
9807c6df9e
1 changed files with 41 additions and 8 deletions
|
@ -877,7 +877,7 @@ echo "Downloading Forgejo runner version: $LATEST_VERSION"
|
||||||
# Download the latest runner
|
# Download the latest runner
|
||||||
wget https://code.forgejo.org/forgejo/runner/releases/download/${LATEST_VERSION}/forgejo-runner-${LATEST_VERSION#v}-linux-amd64
|
wget https://code.forgejo.org/forgejo/runner/releases/download/${LATEST_VERSION}/forgejo-runner-${LATEST_VERSION#v}-linux-amd64
|
||||||
chmod +x forgejo-runner-${LATEST_VERSION#v}-linux-amd64
|
chmod +x forgejo-runner-${LATEST_VERSION#v}-linux-amd64
|
||||||
sudo mv forgejo-runner-${LATEST_VERSION#v}-linux-amd64 /usr/local/bin/forgejo-runner
|
sudo mv forgejo-runner-${LATEST_VERSION#v}-linux-amd64 /usr/bin/forgejo-runner
|
||||||
```
|
```
|
||||||
|
|
||||||
**Alternative: Pin to Specific Version (Recommended for Production)**
|
**Alternative: Pin to Specific Version (Recommended for Production)**
|
||||||
|
@ -889,19 +889,23 @@ cd ~
|
||||||
VERSION="v6.3.1" # Pin to specific version
|
VERSION="v6.3.1" # Pin to specific version
|
||||||
wget https://code.forgejo.org/forgejo/runner/releases/download/${VERSION}/forgejo-runner-${VERSION#v}-linux-amd64
|
wget https://code.forgejo.org/forgejo/runner/releases/download/${VERSION}/forgejo-runner-${VERSION#v}-linux-amd64
|
||||||
chmod +x forgejo-runner-${VERSION#v}-linux-amd64
|
chmod +x forgejo-runner-${VERSION#v}-linux-amd64
|
||||||
sudo mv forgejo-runner-${VERSION#v}-linux-amd64 /usr/local/bin/forgejo-runner
|
sudo mv forgejo-runner-${VERSION#v}-linux-amd64 /usr/bin/forgejo-runner
|
||||||
```
|
```
|
||||||
|
|
||||||
**What this does**:
|
**What this does**:
|
||||||
- **Dynamic approach**: Downloads the latest stable Forgejo Actions runner
|
- **Dynamic approach**: Downloads the latest stable Forgejo Actions runner
|
||||||
- **Version pinning**: Allows you to specify a known-good version for production
|
- **Version pinning**: Allows you to specify a known-good version for production
|
||||||
- **Makes the binary executable** and installs it system-wide for use by the SERVICE_USER
|
- **System installation**: Installs the binary system-wide in `/usr/bin/` for proper Linux structure
|
||||||
|
- **Makes the binary executable** and available system-wide
|
||||||
|
|
||||||
**Production Recommendation**: Use version pinning in production environments to ensure consistency and avoid unexpected breaking changes.
|
**Production Recommendation**: Use version pinning in production environments to ensure consistency and avoid unexpected breaking changes.
|
||||||
|
|
||||||
#### 7.2 Create Systemd Service
|
#### 7.2 Create Systemd Service
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# Create system config directory for Forgejo runner
|
||||||
|
sudo mkdir -p /etc/forgejo-runner
|
||||||
|
|
||||||
sudo tee /etc/systemd/system/forgejo-runner.service > /dev/null << 'EOF'
|
sudo tee /etc/systemd/system/forgejo-runner.service > /dev/null << 'EOF'
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Forgejo Actions Runner
|
Description=Forgejo Actions Runner
|
||||||
|
@ -911,7 +915,7 @@ After=network.target
|
||||||
Type=simple
|
Type=simple
|
||||||
User=SERVICE_USER
|
User=SERVICE_USER
|
||||||
WorkingDirectory=/home/SERVICE_USER
|
WorkingDirectory=/home/SERVICE_USER
|
||||||
ExecStart=/usr/local/bin/forgejo-runner daemon
|
ExecStart=/usr/bin/forgejo-runner daemon --config /etc/forgejo-runner/config.yml
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=10
|
RestartSec=10
|
||||||
|
|
||||||
|
@ -1010,8 +1014,8 @@ To add an existing user as an Administrator of an existing repository in Forgejo
|
||||||
**Step 3: Register the Runner**
|
**Step 3: Register the Runner**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Switch to SERVICE_USER to register the runner
|
# Switch to DEPLOY_USER to register the runner
|
||||||
sudo su - SERVICE_USER
|
sudo su - DEPLOY_USER
|
||||||
|
|
||||||
# Register the runner with your Forgejo instance
|
# Register the runner with your Forgejo instance
|
||||||
forgejo-runner register \
|
forgejo-runner register \
|
||||||
|
@ -1021,14 +1025,38 @@ forgejo-runner register \
|
||||||
--labels "ubuntu-latest,docker" \
|
--labels "ubuntu-latest,docker" \
|
||||||
--no-interactive
|
--no-interactive
|
||||||
|
|
||||||
# Exit SERVICE_USER shell
|
# Exit DEPLOY_USER shell
|
||||||
exit
|
exit
|
||||||
```
|
```
|
||||||
|
|
||||||
**Important**: Replace `your-forgejo-instance` with your actual Forgejo instance URL and `YOUR_REGISTRATION_TOKEN` with the token you copied from Step 2.
|
**Important**: Replace `your-forgejo-instance` with your actual Forgejo instance URL and `YOUR_REGISTRATION_TOKEN` with the token you copied from Step 2.
|
||||||
|
|
||||||
|
**Note**: The `your-forgejo-instance` should be the **base URL** of your Forgejo instance (e.g., `https://git.<your-domain>/`), not the full path to the repository. The runner registration process will handle connecting to the specific repository based on the token you provide.
|
||||||
|
|
||||||
**What this does**:
|
**What this does**:
|
||||||
- Creates the required `.runner` configuration file in the SERVICE_USER's home directory
|
- Creates the required `.runner` configuration file in the DEPLOY_USER's home directory
|
||||||
|
- Registers the runner with your Forgejo instance
|
||||||
|
- Sets up the runner with appropriate labels for Ubuntu and Docker environments
|
||||||
|
|
||||||
|
**Step 4: Set Up System Configuration**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Copy the runner configuration to system location
|
||||||
|
sudo cp /home/DEPLOY_USER/.runner /etc/forgejo-runner/config.yml
|
||||||
|
|
||||||
|
# Set proper ownership and permissions
|
||||||
|
sudo chown SERVICE_USER:SERVICE_USER /etc/forgejo-runner/config.yml
|
||||||
|
sudo chmod 600 /etc/forgejo-runner/config.yml
|
||||||
|
```
|
||||||
|
|
||||||
|
**Important**: Replace `your-forgejo-instance` with your actual Forgejo instance URL and `YOUR_REGISTRATION_TOKEN` with the token you copied from Step 2.
|
||||||
|
|
||||||
|
**Note**: The `your-forgejo-instance` should be the **base URL** of your Forgejo instance (e.g., `https://git.<your-domain>/`), not the full path to the repository. The runner registration process will handle connecting to the specific repository based on the token you provide.
|
||||||
|
|
||||||
|
**What this does**:
|
||||||
|
- Creates the required `.runner` configuration file in the DEPLOY_USER's home directory
|
||||||
|
- Copies the configuration to the system location (`/etc/forgejo-runner/config.yml`)
|
||||||
|
- Sets proper ownership and permissions for SERVICE_USER to access the config
|
||||||
- Registers the runner with your Forgejo instance
|
- Registers the runner with your Forgejo instance
|
||||||
- Sets up the runner with appropriate labels for Ubuntu and Docker environments
|
- Sets up the runner with appropriate labels for Ubuntu and Docker environments
|
||||||
|
|
||||||
|
@ -1044,6 +1072,11 @@ sudo systemctl status forgejo-runner.service
|
||||||
|
|
||||||
**Expected Output**: The service should show "active (running)" status.
|
**Expected Output**: The service should show "active (running)" status.
|
||||||
|
|
||||||
|
**What this does**:
|
||||||
|
- Starts the Forgejo runner daemon as a system service
|
||||||
|
- The runner will now be available to accept and execute workflows from your Forgejo instance
|
||||||
|
- The service will automatically restart if it crashes or the system reboots
|
||||||
|
|
||||||
#### 7.6 Test Runner Configuration
|
#### 7.6 Test Runner Configuration
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
Loading…
Add table
Reference in a new issue