Using my new Raspberry Pi to run an existing GitHub Action
blog.frankel.ch
blog.frankel.ch
I do it by spinning up a VM on my local pc, then running the GitHub Actions software in the VM.
This gives a fully working GitHub Actions runner which I can ssh into directly and muck around with to investigate and get things working.
It's also easy to ensure only the right jobs end up on my runner.
The installer for the GitHub Actions runner asks for optional tag names to use, so I add "jc" (my initials) to the tags.
Then I add a matching "jc" to the "runs-on" clause in the workflow in my fork or PR:
runs-on: [self-hosted, linux, x64, jc]
With that, the GitHub Actions for that workflow only run on my local VM.Works pretty well. :)
---
Official docs for the labelling bit: https://docs.github.com/en/actions/hosting-your-own-runners/...
By who? Why?
In the past, people could modify the GitHub action workflow and run crypto miners on the agents.
But since GitHub changed the default for PR where the actions aren't run anymore that killed that attack vector.
Looks like I'd better do some research. :)
[0] https://github.com/mxschmitt/action-tmate
[1] https://github.com/mxschmitt/action-tmate?tab=readme-ov-file...
It manages running things in other Docker containers for you (or on one of many other runner options) and it worked without any modifications to my workflows. Very pleased with it.
Basically this service:
[Unit]
Description=%N Container
After=docker.service
Requires=docker.service
[Service]
TimeoutSec=3600
Restart=always
WorkingDirectory=/srv/progscrape/progscrape-deploy/github-runners
ExecStartPre=-/usr/bin/docker compose -f %N.yml -p %N stop
ExecStartPre=-/usr/bin/docker compose -f %N.yml -p %N pull
ExecStart=/usr/bin/docker compose -f %N.yml -p %N up
ExecStopPost=-/usr/bin/docker compose -f %N.yml -p %N rm -f
[Install]
WantedBy=multi-user.target
Boots this docker compose definition: services:
github-docker-runner:
image: myoung34/github-runner:latest
restart: "no"
environment:
RUNNER_NAME: progscrape-docker-compose
RUNNER_WORKDIR: /tmp/work
EPHEMERAL: 1
LABELS: management,linux,ARM64
DISABLE_AUTO_UPDATE: 1
env_file:
- github-runner.env
configs:
- github-runner-start
entrypoint: /bin/sh
command: /github-runner-start
security_opt:
# needed on SELinux systems to allow docker container to manage other docker containers
- label:disable
volumes:
- '/var/run/docker.sock:/var/run/docker.sock'
configs:
github-runner-start:
file: runner-start.sh volumes:
- '/var/run/docker.sock:/var/run/docker.sock'
The good old docker security nightmare. That thing has essentially root access to your machine. Just so you know.You might want to move to Podman (which can be executed in rootless mode) so that you can also run podman-in-podman without much hassle (it's officially supported afaik).
But in any case I think it's always better to do docker in docker for security. Also it help control what version of docker is used by the agent and it can then be a different one than the one on the host.
The runs actually occur on your real OS? That seems strange and dangerous.
Just show us that mess of your's :)
https://github.com/nektos/actIf you meant to ask how to run the GitHub actions code without GitHub then the sibling comment would help for most tasks but has limitations.
https://github.com/mutablelogic/docker-action-runner
Running the actions in a docker container is not ideal by any means. The authors of Github Actions do not have a stable API between the actions runner and whatever triggers them on their server side; you need to keep the docker container up-to-date every few months, it's not a "fire and forget" thing.