This system provides a complete solution for running self-hosted GitHub runners with Flipper Zero devices for automated testing, flashing, and QA tasks. The system includes a runner management service, monitoring capabilities, and handles the device firmware flashing lifecycle.
The system consists of several components:
- Docker-based GitHub runner containers
- Python management scripts
- Systemd services
- Monitoring solution with Prometheus integration
- Initialization: The systemd service starts a Python script that locates the specified ST-Link and Flipper devices.
- Repair Mode: Docker container runs in 'REPAIR' state first, which flashes the latest release firmware to the Flipper device.
- Normal Mode: After successful firmware flashing, the container restarts in 'NORMAL' state and registers as a GitHub self-hosted runner.
- Job Execution: The runner picks up jobs with matching tags from GitHub and executes them.
- Monitoring: A dedicated monitoring service tracks the status of all runners and provides metrics.
sudo ./installer.sh FLIPPER_ID ST_LINK_ID
Example:
sudo ./installer.sh flip_Testii 002F00000000000000000001
This will:
- Install required dependencies
- Set up the necessary directories
- Configure the systemd service
- Set up logging
sudo ./monitor-installer.sh
This will:
- Install the monitoring service
- Configure Prometheus metrics collection
- Set up log rotation
- Enable the monitoring systemd service
Create a configuration file at /var/lib/flipper-docker/flipper-docker.cfg
:
[github]
access_token = GITHUB_ACCESS_TOKEN
org_name = GITHUB_ORG_NAME
app_id = GITHUB_APP_ID
app_private_key = GITHUB_APP_PRIVATE_KEY
[gelf]
host = GELF_HTTP_UPLOAD_URL
port = GELF_HTTP_UPLOAD_PORT
username = GELF_HTTP_UPLOAD_BASIC_AUTH_USER
password = GELF_HTTP_UPLOAD_BASIC_AUTH_PASS
Where:
GITHUB_ACCESS_TOKEN
- GitHub Personal Access TokenGITHUB_ORG_NAME
- GitHub organization nameGITHUB_APP_ID
- GitHub App ID (if using GitHub App authentication)GITHUB_APP_PRIVATE_KEY
- GitHub App private key (if using GitHub App authentication)GELF_HTTP_UPLOAD_*
- Optional GELF logging configuration
For each Flipper + ST-Link pair, a dedicated systemd service is created:
[Unit]
Description=Dockerized github runner FLIPPER_SHORT_NAME
After=docker.service
Requires=docker.service
[Service]
TimeoutStartSec=0
Restart=always
ExecStart=sudo python3 /usr/bin/flipper_docker.py FLIPPER_SHORT_NAME ST_LINK_DEVICE_ID GITHUB_RUNNER_TAG
KillSignal=SIGINT
[Install]
WantedBy=multi-user.target
Example:
ExecStart=sudo python3 /usr/bin/flipper_docker.py flip_Testii 002F00000000000000000001 FlipperZeroTest
The monitoring system collects metrics about runner state, container status, and job execution.
The following metrics are available in Prometheus format:
github_runner_state
- Current state of GitHub runners (offline, starting, repairing, online, error, flashing)github_runner_container_status
- Docker container statusgithub_runner_run_level
- Current run level (REPAIR or NORMAL)github_runner_service_status
- Systemd service statusgithub_runner_uptime_seconds
- Runner uptimegithub_runner_job_info
- Information about currently running jobsgithub_runner_job_runtime_seconds
- Duration of current job
The monitoring service outputs metrics to /var/lib/node_exporter/textfile_collector/
, ready to be picked up by Prometheus Node Exporter.
Make sure to configure Node Exporter to scrape the metrics directory.
- Runner logs:
/opt/<FLIPPER_ID>/logs/
- Monitoring logs:
/var/log/github-runner-metrics.log
Log rotation is configured automatically to prevent excessive disk usage.
Runners go through the following states:
- Offline: Not running
- Starting: Service is initializing
- Repairing: In repair mode, preparing to flash firmware
- Flashing: Actively flashing firmware to Flipper
- Online: Registered with GitHub and ready for jobs
- Error: Encountered an error during operation
-
Device not found
- Check USB connections
- Verify ST-Link and Flipper IDs
-
Container fails to start
- Check Docker service status
- Verify configuration file
-
Runner doesn't register with GitHub
- Check GitHub access token permissions
- Verify network connectivity
# Check runner service status
systemctl status github-runner-<FLIPPER_ID>
# View runner logs
journalctl -u github-runner-<FLIPPER_ID> -f
# Check monitor service status
systemctl status github-runner-monitor
# View monitor logs
tail -f /var/log/github-runner-metrics.log
# Check Docker container status
docker ps -a | grep <FLIPPER_ID>