gha-main
Write GitHub Actions in Rust!
This crate provides two convenience macros to make it easier to write GitHub Actions in Rust.
How to use:
- Annotate your
main()function with#[gha_main]. - Add return type
GitHubActionResult. - Use the
?operator to propagate errors. - Return ouputs (anything that implements
Display) to the action runner with thegha_output!()macro so they can be used in later workflow steps or other actions.
Example usage:
use env;
use ;
Values wrapped in gha_output!() are returned to the runner with the output name equal to the Rust variable name. In the example above, if the action is called with input "5", the parsed_u32 output will be set to 5.
Errors propagated via the ? operator are returned to the runner as the error output. The error values are formatted using [anyhow::Error]'s Display implementation.
Example actions
The /example-actions folder contains several examples that demonstrate how GitHub Actions can be written in Rust.
License: Apache-2.0 OR MIT