Skip to main content

Crate actions_rs

Crate actions_rs 

Source
Expand description

§actions-rs

A zero-dependency toolkit for writing GitHub Actions in Rust — an independent, unofficial Rust port of @actions/core (faithful API and semantics, with deliberate safety-first departures; not affiliated with or endorsed by GitHub or the @actions/toolkit project).

It speaks the GitHub Actions workflow-command and environment-file protocols so your action can:

  • emit notice / warning / error annotations with file + line/column ranges (Annotation, log),
  • group and mask log output, and pause command interpretation (log::group, log::mask, log::stop_commands),
  • read typed, validated inputs (input),
  • set step outputs, saved state, env vars and PATH (output) — using modern env files, with deprecated-command fallback only for output/state,
  • build a rich job summary (Summary),
  • detect and inspect the runtime (env).

Pure stdout commands are infallible; operations that touch the filesystem or parse input return Result.

§Quick start

use actions_rs::{Annotation, log};

if actions_rs::env::is_github_actions() {
    log::info("running inside GitHub Actions");
}

// A located warning, rendered as a workflow command on stdout.
Annotation::new()
    .file("src/lib.rs")
    .line(1)
    .title("example")
    .warning("this is just a demo");

// `format!`-style macros are exported at the crate root.
actions_rs::warning!("disk {}% full", 92);

// A group that closes even if the closure panics.
let answer = actions_rs::group!("compute", { 6 * 7 });
assert_eq!(answer, 42);

Re-exports§

pub use annotation::Annotation;
pub use annotation::AnnotationKind;
pub use annotation::AnnotationSpan;
pub use command::WorkflowCommand;
pub use env::Context;
pub use env::RunnerArch;
pub use env::RunnerOs;
pub use error::Error;
pub use error::Result;
pub use input::InputOptions;
pub use summary::Cell;
pub use summary::Summary;
pub use summary::SummaryText;

Modules§

annotation
Annotation builder for notice / warning / error commands.
command
Low-level workflow-command construction and emission.
env
Runtime detection and typed access to the GitHub Actions environment.
error
Error type for fallible operations (environment-file writes, typed input parsing, oversized job summaries).
input
Typed access to action inputs.
log
Logging, grouping, masking and command-flow control.
output
Step outputs, saved state, exported variables and PATH additions.
prelude
Common imports for action authors: use actions_rs::prelude::*;.
summary
Fluent builder for the job summary (GITHUB_STEP_SUMMARY).

Macros§

debug
debug!("x = {x}")crate::log::debug with format! arguments.
error
error!("...")crate::log::error with format! arguments.
group
group!("name", { ... }) runs the block inside a collapsible group that is closed even on panic. Evaluates to the block’s value.
info
info!("...")crate::log::info with format! arguments.
notice
notice!("...")crate::log::notice with format! arguments.
warning
warning!("...")crate::log::warning with format! arguments.