Expand description
gha-runner runs Github Actions workflows. It supports pluggable backends
via the RunnerBackend trait, and provides a LocalDockerBackend implementation
that runs workflows using local docker containers. You can also analyze the
structure of workflow jobs and modify step execution.
§Example
use gha_runner::*;
let images: DockerImageMapping = DockerImageMapping {
ubuntu_18_04: "ghcr.io/catthehacker/ubuntu:act-18.04".into(),
ubuntu_20_04: "ghcr.io/catthehacker/ubuntu:act-20.04".into(),
};
let runtime = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap();
runtime.block_on(async move {
run_workflow_with_local_backend(
"Pernosco",
"github-actions-test",
"6475d0f048a72996e3bd559cdd3763f53fe3d072",
".github/workflows/build.yml",
"Build+test (stable, ubuntu-18.04)",
&images,
LocalDockerOptions::default(),
).await;
});§Lower-level API
- Fill out a
RunnerContext - Call
Runner::new()to create aRunner - Call
Runner::job_descriptions()to get a list ofJobDescriptionsand pick a job - Call
Runner::job_runner()to create aJobRunner - Call
JobRunner::container_images()to get a list of Docker container images that will be needed, and create one container per image - Call
JobRunner::run_next_step()repeatedly to run each job step, untilnext_step_index() >= step_count()
Structs§
- Container
Id - Index into
JobRunner::containers - Container
Image - A full Docker container image name, e.g
ghcr.io/catthehacker/ubuntu:js-18.04 - Docker
Image Mapping - Assigns full docker image names to GHA ‘runs-on’ names
- Error
Context - This describes wha we know about the source of an error.
- JobDescription
- A description of a job in a workflow.
- JobRunner
- Runs a specific Job.
The simplest way to use this is to repeatedly call
run_next_step()untilnext_step_index() >= step_count(). - Local
Docker Backend - Runs a GHA workflow using local Docker containers and the docker CLI.
- Local
Docker Options - Optional parameters for
run_workflow_with_local_backend - Runner
- Analyzes and runs a specific Github Actions workflow.
- Runner
Context - This contains various configuration values needed to run a Github Actions workflow. Most of these values are exposed to actions via standard GHA environment variables.
- Runner
Error - Errors returned by this crate.
- Step
Index - An index into the steps in the workflow YAML. This is not the same thing as Github’s “step number”, which includes invisible steps like job creation and isn’t always numbered consecutively.
Enums§
- Error
Context Root ErrorContextRootdescribes what we were processing when an error occurred.- Runner
Error Kind - Details about an error we encountered.
- Workflow
Result - The result of
run_workflow_with_local_backend
Traits§
- Runner
Backend - A backend that can run tasks in containers.
Functions§
- get_
workflow - Either fetches workflow data from the repository (if ‘workflow’ is a relative path) or reads it from a file on the local filesystem with that name. Panics if something goes wrong.
- run_
workflow_ with_ local_ backend - Run a complete workflow using the local docker backend and DefaultImageMapping.
If
workflowis an absolute path we read that file to get the workflow data, otherwise it’s a repo-relative path and we fetch the workflow data from the repo. Panics if something goes wrong. - zero_
access_ token - Returns a Github personal access token that has no rights to access anything. It will work for read-only access to public resources. For anything more you have to supply your own token.
Type Aliases§
- Output
Handler - A callback that receives stdout or stderr data from a step.