Ephemeral GCE GitHub self-hosted runner.
jobs:
create-runner:
runs-on: ubuntu-latest
outputs:
label: ${{ steps.create-runner.outputs.label }}
steps:
- id: create-runner
uses: PluralisResearch/gce-github-runner@main
with:
token: ${{ secrets.GH_SA_TOKEN }}
project_id: ${{ secrets.GCP_PROJECT_ID }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
image_project: ubuntu-os-cloud
image_family: ubuntu-2204-lts
max_run_duration: 1h
github_job_start_ttl_seconds: 300
instance_labels: createdby=ci,environment=test
test:
needs: create-runner
runs-on: ${{ needs.create-runner.outputs.label }}
steps:
- run: echo "This runs on the GCE VM"create-runnercreates the GCE VM and registers the runner with unique labeltestuses the runner- the runner VM will be automatically shut down after the workflow via self-hosted runner hook
max_run_durationprovides a platform-enforced deletion deadline for both Spot and standard VMs (default:3d)github_job_start_ttl_secondsdeletes a registered runner if no job starts before the deadline (default:0, disabled)instance_labelsadds comma-separated GCE labels alongside the action's internal runner labelsfallback_to_on_demandretries a Spot request as a standard VM only when GCE reports exhausted capacity (default:false)
See inputs and descriptions here.
The GCE runner image should have at least:
gcloudgit- (optionally) GitHub Actions Runner (see
actions_preinstalledparameter)
- Test Workflow: Test workflow.
From GitHub's documentation:
We recommend that you only use self-hosted runners with private repositories. This is because forks of your repository can potentially run dangerous code on your self-hosted runner machine by creating a pull request that executes the code in a workflow.
If you need EC2/AWS self-hosted runner, check out machulav/ec2-github-runner.