Crate ghactions_derive

source ·
Expand description

ghactions-derive is a library that provides derive macros for GitHub Actions in Rust.

§Example

use ghactions::prelude::*;

#[derive(Actions, Debug, Clone)]
#[action(
    path = "./action.yml",
    name = "My Action",
    description = "My Action Description"
)]
pub struct MyAction {
    /// My Input
    #[input(
        description = "My Input",
        default = "false"
    )]
    my_input: bool,

    #[input(
        name = "custom",
        description = "My Custom Input",
    )]
    my_custom: String,

    #[input(
        description = "Multi Input",
        split = ",",
    )]
    multi_input: Vec<String>,

    #[output(description = "Output Value")]
    my_output: String,
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Set the environment variables

    let action = MyAction::init()?;

    println!("My Input   :: {}", action.my_input);


    MyAction::set_output("my_output", "My Output Value")?;

    Ok(())
}

Derive Macros§

  • Derive macro for GitHub Actions