Crate gha_runner[][src]

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 a Runner
  • Call Runner::job_descriptions() to get a list of JobDescriptions and pick a job
  • Call Runner::job_runner() to create a JobRunner
  • 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, until next_step_index() >= step_count()

Structs

Index into JobRunner::containers

A full Docker container image name, e.g ghcr.io/catthehacker/ubuntu:js-18.04

Assigns full docker image names to GHA ‘runs-on’ names

This describes wha we know about the source of an error.

A description of a job in a workflow.

Runs a specific Job. The simplest way to use this is to repeatedly call run_next_step() until next_step_index() >= step_count().

Runs a GHA workflow using local Docker containers and the docker CLI.

Optional parameters for run_workflow_with_local_backend

Analyzes and runs a specific Github Actions workflow.

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.

Errors returned by this crate.

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

ErrorContextRoot describes what we were processing when an error occurred.

Details about an error we encountered.

The result of run_workflow_with_local_backend

Traits

A backend that can run tasks in containers.

Functions

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 a complete workflow using the local docker backend and DefaultImageMapping. If workflow is 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.

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 Definitions

A callback that receives stdout or stderr data from a step.