diff --git a/CI_CD_PIPELINE_SETUP_GUIDE.md b/CI_CD_PIPELINE_SETUP_GUIDE.md index 28bc15a..5a679a8 100644 --- a/CI_CD_PIPELINE_SETUP_GUIDE.md +++ b/CI_CD_PIPELINE_SETUP_GUIDE.md @@ -867,6 +867,8 @@ chmod 600 ~/.ssh/config #### 7.1 Download Runner +**Important**: Run this step as the **DEPLOY_USER** (not root or SERVICE_USER). The DEPLOY_USER handles deployment tasks including downloading and installing the Forgejo runner. + ```bash cd ~ @@ -900,38 +902,7 @@ sudo mv forgejo-runner-${VERSION#v}-linux-amd64 /usr/bin/forgejo-runner **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 -After=network.target - -[Service] -Type=simple -User=SERVICE_USER -WorkingDirectory=/home/SERVICE_USER -ExecStart=/usr/bin/forgejo-runner daemon --config /etc/forgejo-runner/config.yml -Restart=always -RestartSec=10 - -[Install] -WantedBy=multi-user.target -EOF -``` - -#### 7.3 Enable Service - -```bash -sudo systemctl daemon-reload -sudo systemctl enable forgejo-runner.service -``` - -#### 7.4 Register Runner +#### 7.2 Register Runner **Important**: The runner must be registered with your Forgejo instance before it can start. This creates the required `.runner` configuration file. @@ -1060,7 +1031,41 @@ sudo chmod 600 /etc/forgejo-runner/config.yml - Registers the runner with your Forgejo instance - Sets up the runner with appropriate labels for Ubuntu and Docker environments -#### 7.5 Start Service +**Step 5: Create and Enable 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 +After=network.target + +[Service] +Type=simple +User=SERVICE_USER +WorkingDirectory=/home/SERVICE_USER +ExecStart=/usr/bin/forgejo-runner daemon --config /etc/forgejo-runner/config.yml +Restart=always +RestartSec=10 + +[Install] +WantedBy=multi-user.target +EOF + +# Enable the service +sudo systemctl daemon-reload +sudo systemctl enable forgejo-runner.service +``` + +**What this does**: +- Creates the systemd service configuration for the Forgejo runner +- Points the service to use the configuration file we just set up +- Enables the service to start automatically on boot +- Sets up proper restart behavior for reliability + +#### 7.3 Start Service ```bash # Start the Forgejo runner service @@ -1077,7 +1082,7 @@ sudo systemctl status forgejo-runner.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.4 Test Runner Configuration ```bash # Check if the runner is running