ghactions 0.9.2

GitHub Actions Crate
Documentation

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 Template (cargo-generate)

You can use the cargo-generate tool to create a new GitHub Action project with the library.

cargo generate --git https://github.com/42ByteLabs/ghactions

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.