{"id":21029412,"url":"https://github.com/42bytelabs/ghactions","last_synced_at":"2025-05-15T11:31:53.580Z","repository":{"id":51129198,"uuid":"520249567","full_name":"42ByteLabs/ghactions","owner":"42ByteLabs","description":"Rust GitHub Actions Library","archived":false,"fork":false,"pushed_at":"2025-05-12T22:48:58.000Z","size":464,"stargazers_count":8,"open_issues_count":6,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-13T12:18:49.059Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://docs.rs/ghactions/latest/ghactions","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/42ByteLabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-08-01T20:12:50.000Z","updated_at":"2025-04-30T18:28:32.000Z","dependencies_parsed_at":"2022-08-12T22:40:32.587Z","dependency_job_id":"8f422817-66c7-47a7-8178-836ab1b0b69a","html_url":"https://github.com/42ByteLabs/ghactions","commit_stats":{"total_commits":23,"total_committers":2,"mean_commits":11.5,"dds":"0.17391304347826086","last_synced_commit":"120cb79c55de999082cb8948d8a733f478df1a37"},"previous_names":["geekmasher/gh_actions","42bytelabs/ghactions","geekmasher/ghactions"],"tags_count":36,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/42ByteLabs%2Fghactions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/42ByteLabs%2Fghactions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/42ByteLabs%2Fghactions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/42ByteLabs%2Fghactions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/42ByteLabs","download_url":"https://codeload.github.com/42ByteLabs/ghactions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254330721,"owners_count":22053034,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-19T12:12:17.433Z","updated_at":"2025-05-15T11:31:53.556Z","avatar_url":"https://github.com/42ByteLabs.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- markdownlint-disable --\u003e\n\u003cdiv align=\"center\"\u003e\n\u003ch1\u003eGitHub Actions library written in Rust\u003c/h1\u003e\n\n[![GitHub](https://img.shields.io/badge/github-%23121011.svg?style=for-the-badge\u0026logo=github\u0026logoColor=white)][github]\n[![Crates.io Version](https://img.shields.io/crates/v/ghactions?style=for-the-badge)][crates-io]\n[![Crates.io Downloads (recent)](https://img.shields.io/crates/dr/ghactions?style=for-the-badge)][crates-io]\n[![GitHub Stars](https://img.shields.io/github/stars/42ByteLabs/ghactions?style=for-the-badge)][github]\n[![Licence](https://img.shields.io/github/license/Ileriayo/markdown-badges?style=for-the-badge)][license]\n\n\u003c/div\u003e\n\u003c!-- markdownlint-restore --\u003e\n\n`GHActions` is a Rust based library for helping users write amazing GitHub Actions in Rust!\n\n## 📦 Install\n\nRun the following command to add the library to your `Cargo.toml` file:\n\n```bash\ncargo add ghactions\n```\n\n## 📚 Features\n\n- Easy to use\n- Validate GitHub Actions files\n- Automatic input and output parsing\n- Generate `action.yml` file automatically from code\n  - feature: `generate`\n- [Octocrab][octocrab] support\n  - feature: `octocrab`\n- Actions ToolCache support\n  - Locating tools in the toolcache\n  - feature: `toolcache`\n\n## 🚀 Usage\n\nHere is a simple example of how to use the library:\n\n```rust\nuse ghactions::prelude::*;\n\n#[derive(Actions)]\nstruct MyAction {}\n\nfn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    // Initialise the Action\n    let action = MyAction::init()?;\n\n    group!(\"Main Workflow\");\n\n    // Do something...\n\n    Ok(())\n}\n```\n\n### Using Template (cargo-generate)\n\nYou can use the [cargo-generate](cargo-generate) tool to create a new GitHub Action project with the library.\n\n```bash\ncargo generate --git https://github.com/42ByteLabs/ghactions\n```\n\n### Advance Usage\n\nAnother feature of `ghactions` is the ability to automatically parse inputs and outputs from the action.\n\n```rust\nuse ghactions::prelude::*;\n\n#[derive(Actions, Debug, Clone)]\n#[action(\n    // Action Name\n    name = \"My Action\",\n    // Action Description\n    description = \"My Action Description\",\n)]\nstruct MyAction {\n    /// My Input\n    #[input(\n        // Change the name of the input from `my_mode` to `mode`\n        name = \"mode\",\n        // Input Description\n        description = \"My Input Description\",\n        // Default Value\n        default = \"default\"\n    )]\n    my_mode: String,\n\n    // Automatical type conversion\n    #[input(\n        // Input Description\n        description = \"My Input Description\",\n        default = \"42\",\n    )]\n    my_int: i32,\n\n    // Multiple Inputs\n    #[input(\n        // Input Description\n        description = \"My Second Input Description\",\n        // Automatically split the input by `,`\n        split = \",\",\n    )]\n    mutiple: Vec\u003cString\u003e,\n\n    // Output called `version`\n    #[output(\n        // Output Description\n        description = \"My Output Description\",\n    )]\n    version: String,\n}\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    // Initialise the Action\n    let action = MyAction::init()?;\n\n    group!(\"Main Workflow\");\n    info!(\"Action :: {:?}\", action);\n\n    info!(\"My Input Mode :: `{}`\", action.my_mode);\n    info!(\"My Multiple Input :: `{:?}`\", action.mutiple);\n    info!(\"My Output Version :: `{}`\", action.version);\n\n    groupend!();\n\n    // Using the toolcache feature\n    group!(\"ToolCache\");\n    \n    // Load the ToolCache from the `examples/toolcache` folder\n    let toolcache = ToolCache::from(\"examples/toolcache\");\n    // Find the Node.js 18.4.0 tool\n    let tool = toolcache.find(\"node\", \"18.4.0\").await?;\n    info!(\"Tool :: {:?}\", tool);\n\n    groupend!();\n\n    // There are 3 ways to set the output\n    group!(\"Set Outputs\");\n\n    // Using the dynamically name Action method\n    action.output_version(\"1.0.0\");\n    // Using the `set_output` method\n    MyAction::set_output(\"version\", \"1.0.0\")?;\n    // Or the Macro `setoutput!` directly\n    setoutput!(\"version\", \"1.0.0\");\n\n    groupend!();\n\n    Ok(())\n}\n```\n\n### Generating the `action.yml` file\n\nThe `generate` feature will allow you to generate the `action.yml` file from the code.\nThere are 3 ways to generate the `action.yml` file:\n\n- [`image` mode](./examples/advanced): \n  - This will generate the `action.yml` file with a container `image`.\n- [`entrypoint` mode](./examples/entrypoint):\n  - This will generate a composite Action with an entrypoint script.\n- [`installer` mode](./examples/installer):\n  - This will generate a composite Action with an installer script.\n\n```rust no_run\nuse ghactions::prelude::*;\n\n#[derive(Actions, Debug, Clone)]\n#[action(\n    // Container / Docker file to supply the Action\n    image = \"./examples/advanced/Dockerfile\",\n    // [Optional] Supply a entrypoint for the container image\n    entrypoint = \"./examples/entrypoint/entrypoint.sh\",\n)]\nstruct ContainerAction {\n    // ...\n}\n\n#[derive(Actions, Debug, Clone)]\n#[action(\n    // Entrypoint is a Composite Action with an entrypoint script\n    entrypoint = \"./examples/entrypoint/entrypoint.sh\",\n)]\nstruct EntrypointAction {\n    // ...\n}\n\n#[derive(Actions, Debug, Clone)]\n#[action(\n    // Composite Action with an installer script\n    installer\n)]\nstruct InstallerAction {\n    // ...\n}\n\n```\n\nAt build time, the `action.yml` file will be generated with the following content.\n\n### Using Octocrab\n\nEnabling the `octocrab` feature will allow you to use the [Octocrab][octocrab] library.\n\n```rust\nuse ghactions::prelude::*;\n\n#[derive(Actions, Debug, Clone)]\nstruct MyAction {}\n\n#[tokio::main]\nasync fn main() -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    let action = MyAction::init()?;\n\n    group!(\"Octocrab\");\n    // Automatically setup Octocrab with the GitHub Instance and Token\n    let octocrab = action.octocrab()?;\n\n    // ... Do something...\n\n    Ok(())\n}\n```\n\n## 🦸 Support\n\nPlease create [GitHub Issues][github-issues] if there are bugs or feature requests.\n\nThis project uses [Semantic Versioning (v2)][semver] and with major releases, breaking changes will occur.\n\n## 📓 License\n\nThis project is licensed under the terms of the MIT open source license.\nPlease refer to [MIT][license] for the full terms.\n\n\u003c!-- Resources --\u003e\n[license]: ./LICENSE\n[semver]: https://semver.org/\n[github]: https://github.com/42ByteLabs/ghactions\n[github-issues]: https://github.com/42ByteLabs/ghactions/issues\n[crates-io]: https://crates.io/crates/ghactions\n[examples]: ./examples\n[octocrab]: https://crates.io/crates/octocrab\n[cargo-generate]: https://crates.io/crates/cargo-generate\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F42bytelabs%2Fghactions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F42bytelabs%2Fghactions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F42bytelabs%2Fghactions/lists"}