diff --git a/CI_CD_PIPELINE_SETUP_GUIDE.md b/CI_CD_PIPELINE_SETUP_GUIDE.md index 955a3a1..28bc15a 100644 --- a/CI_CD_PIPELINE_SETUP_GUIDE.md +++ b/CI_CD_PIPELINE_SETUP_GUIDE.md @@ -877,7 +877,7 @@ echo "Downloading Forgejo runner version: $LATEST_VERSION" # Download the latest runner 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 -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)** @@ -889,19 +889,23 @@ cd ~ VERSION="v6.3.1" # Pin to specific version wget https://code.forgejo.org/forgejo/runner/releases/download/${VERSION}/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**: - **Dynamic approach**: Downloads the latest stable Forgejo Actions runner - **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. #### 7.2 Create Systemd Service ```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' [Unit] Description=Forgejo Actions Runner @@ -911,7 +915,7 @@ After=network.target Type=simple User=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 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** ```bash -# Switch to SERVICE_USER to register the runner -sudo su - SERVICE_USER +# Switch to DEPLOY_USER to register the runner +sudo su - DEPLOY_USER # Register the runner with your Forgejo instance forgejo-runner register \ @@ -1021,14 +1025,38 @@ forgejo-runner register \ --labels "ubuntu-latest,docker" \ --no-interactive -# Exit SERVICE_USER shell +# Exit DEPLOY_USER shell exit ``` **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./`), 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 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./`), 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 - 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. +**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 ```bash