| Crates.io | gha_main |
| lib.rs | gha_main |
| version | 0.0.5 |
| created_at | 2023-05-25 19:09:29.938164+00 |
| updated_at | 2023-05-28 21:47:38.259738+00 |
| description | Convenience macros for writing GitHub Actions in Rust |
| homepage | |
| repository | https://github.com/avsaase/gha_main |
| max_upload_size | |
| id | 874545 |
| size | 27,431 |
This crate provides two convenience macros to make it easier to write GitHub Actions in Rust.
How to use:
main() function with #[gha_main].GitHubActionResult.? operator to propagate errors.Display) to the action runner
with the gha_output!() macro so they can be used in later workflow steps
or other actions.Example usage:
use std::env;
use gha_main::{gha_main, gha_output, GitHubActionResult};
#[gha_main]
fn main() -> GitHubActionResult {
let args: Vec<String> = env::args().collect();
let input = &args[1];
let parsed_u32 = input.parse::<u32>()?;
gha_output!(parsed_u32);
Ok(())
}
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.
The /example-actions folder contains several examples that demonstrate how GitHub Actions can be written in Rust.
License: Apache-2.0 OR MIT