14 releases (8 breaking)

new 0.9.1 Jun 8, 2024
0.8.0 Jun 2, 2024
0.5.0 Jul 17, 2023
0.4.3 Oct 21, 2022

#395 in Development tools

Download history 2/week @ 2024-02-21 3/week @ 2024-02-28 4/week @ 2024-03-13 20/week @ 2024-03-27 34/week @ 2024-04-03 113/week @ 2024-05-22 179/week @ 2024-05-29

292 downloads per month

MIT license

49KB
598 lines

GitHub Actions library written in Rust

GitHub Crates.io Version Crates.io Downloads (recent) GitHub Stars Licence

This is a Rust GitHub Actions library which should help those of us that write GitHub Actions in Rust.

📦 Install

Run the following command to add the library to your Cargo.toml file:

cargo add ghactions

📚 Features

  • Easy to use
  • Generate action.yml file automatically from code
  • Validate GitHub Actions files
  • Automatical input and output parsing
  • Octocrab support

🚀 Usage

Here is a simple example of how to use the library:

use ghactions::prelude::*;

#[derive(Actions, Debug, Clone)]
#[action(
    name = "My Action",
    description = "My Action Description",
)]
struct MyAction {
    /// My Input
    #[input()]
    mode: bool,

    // Output called `version`
    #[output()]
    version: String,
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Initialise the Action
    let action = MyAction::init()?;

    info!("Action :: {:?}", action);

    group!("Main Workflow");

    info!("My Input Mode :: `{}`", action.mode);
    info!("My Output Version :: `{}`", action.version);

    groupend!();

    Ok(())
}

Using Octocrab

use ghactions::prelude::*;

#[derive(Actions, Debug, Clone)]
struct MyAction {}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let action = MyAction::init()?;

    group!("Octocrab");
    let octocrab = action.octocrab()?;

    // ... Do something...

    Ok(())
}

🦸 Support

Please create GitHub Issues if there are bugs or feature requests.

This project uses Semantic Versioning (v2) and with major releases, breaking changes will occur.

📓 License

This project is licensed under the terms of the MIT open source license. Please refer to MIT for the full terms.

Dependencies

~13–25MB
~399K SLoC