{"id":15478502,"url":"https://github.com/jcbhmr/go-actions-toolkit","last_synced_at":"2025-04-06T18:35:18.937Z","repository":{"id":231397532,"uuid":"781160399","full_name":"jcbhmr/go-actions-toolkit","owner":"jcbhmr","description":"🐿️ GitHub Actions toolkit for your Go-based GitHub Actions","archived":false,"fork":false,"pushed_at":"2024-04-22T17:06:09.000Z","size":68,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-05-23T05:14:38.386Z","etag":null,"topics":["actions","github","github-actions","github-api","go","golang","library","monorepo","octokit","tool","toolkit"],"latest_commit_sha":null,"homepage":"","language":"Go","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/jcbhmr.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}},"created_at":"2024-04-02T21:23:28.000Z","updated_at":"2024-06-19T07:46:57.171Z","dependencies_parsed_at":"2024-06-19T07:46:46.668Z","dependency_job_id":"e56c51b5-57e7-40b6-915e-0dc6173ce62b","html_url":"https://github.com/jcbhmr/go-actions-toolkit","commit_stats":null,"previous_names":["jcbhmr/actions-toolkit.go","jcbhmr/go-actions-toolkit"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcbhmr%2Fgo-actions-toolkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcbhmr%2Fgo-actions-toolkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcbhmr%2Fgo-actions-toolkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcbhmr%2Fgo-actions-toolkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jcbhmr","download_url":"https://codeload.github.com/jcbhmr/go-actions-toolkit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247533513,"owners_count":20954395,"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":["actions","github","github-actions","github-api","go","golang","library","monorepo","octokit","tool","toolkit"],"created_at":"2024-10-02T04:05:11.682Z","updated_at":"2025-04-06T18:35:18.918Z","avatar_url":"https://github.com/jcbhmr.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"![🚧 Under construction 👷‍♂️](https://i.imgur.com/LEP2R3N.png)\n\n- [x] Create go-actions-toolkit\n- [x] ⭐ github.com/jcbhmr/go-actions-toolkit/core\n- [ ] 🤢 github.com/jcbhmr/go-actions-toolkit/exec\n- [ ] github.com/jcbhmr/go-actions-toolkit/glob\n- [ ] 🤢 github.com/jcbhmr/go-actions-toolkit/http-client\n- [ ] 🤢 github.com/jcbhmr/go-actions-toolkit/io\n- [ ] ⭐ github.com/jcbhmr/go-actions-toolkit/tool-cache\n- [x] ⭐ github.com/jcbhmr/go-actions-toolkit/github\n- [ ] github.com/jcbhmr/go-actions-toolkit/artifact\n- [ ] github.com/jcbhmr/go-actions-toolkit/cache\n- [ ] [configure-executable-action](https://github.com/jcbhmr/configure-executable-action)\n- [ ] [configure-wasmtime-action](https://github.com/jcbhmr/configure-wasmtime-action)\n- [ ] [hello-world-go-action](https://github.com/jcbhmr/hello-world-go-action)\n\n# GitHub Actions Toolkit for Go\n\n🐿️ GitHub Actions toolkit for your Go-based GitHub Actions\n\n\u003ctable align=center\u003e\u003ctd\u003e\n\n```go\n// ✅\nname := try1(core.GetInput(\"name\", nil))\ncore.Notice(fmt.Sprintf(\"Hello, %s!\", name))\n\n// 🐙🐱\ntoken := try1(core.GetInput(\"token\", nil))\nclient := try1(github.GetGoGithubClient(token, nil))\nif github.Context.EventName != \"push\" {\n  panic(\"🤷‍♂️\")\n}\nactor := github.Context.Actor\nrepo := github.Context.Payload[\"repository\"](map[string]any)[\"fullName\"](string)\nfmt.Printf(\"%s pushed to %s\\n\", actor, repo)\n\n// 🔨\nurl := \"https://example.org/tool.tgz\";\npath := try1(tc.DownloadTool(url, nil, nil, nil))\npath = try1(tc.ExtractTar(path, nil, nil))\nfmt.Printf(\"%s extracted to %s\\n\", url, path)\n\n// 🍦\nfiles := try1(try1(glob.Create(\"**/*.rs\")).Glob());\nfmt.Printf(\"The files are %v\\n\", files)\nhash := try1(glob.HashFiles(\"*.json\"));\nfmt.Printf(\"Config hash is %s\\n\", hash)\n```\n\n\u003c/table\u003e\n\n\u003cp align=center\u003e\n  \u003ca href=\"https://docs.rs/actions-core/latest/actions_core\"\u003edocs.rs/actions-core\u003c/a\u003e\n  | \u003ca href=\"https://github.com/jcbhmr/hello-world-rust-action\"\u003ehello-world-rust-action\u003c/a\u003e\n  | \u003ca href=\"https://github.com/actions/toolkit\"\u003eOfficial actions/toolkit\u003c/a\u003e\n\u003c/p\u003e\n\n😵 Don't know where to start? Read the [🦀 How to write your GitHub Actions in Rust](https://dev.to/#) post. 🚀\n\n- **[actions-core2](./crates/actions-core2):** ✅ Get inputs, set outputs, and other basic operations for GitHub Actions\n- **[actions-exec](./crates/actions-exec):** 🏃‍♂️ Easier interface for running subprocesses in GitHub Actions\n- **[actions-glob](./crates/actions-glob):** 🍦 Glob expression library for GitHub Actions\n- **[actions-http-client](./crates/actions-http-client):** 📞 An HTTP client optimized for GitHub Actions\n- **[actions-io](./crates/actions-io):** ✏️ Common I/O utilities as a single package for GitHub Actions\n- **[actions-tool-cache](./crates/actions-tool-cache):** 🔨 Functions for downloading and caching tools in GitHub Actions\n- **[actions-github](./crates/actions-github):** :octocat: Provides an Octokit.rs client already setup in the GitHub Actions context\n- **[actions-artifact](./crates/actions-artifact):** 💾 Functions to interact with Actions artifacts\n- **[actions-cache](./crates/actions-cache):** 🎯 Functions to cache dependencies and build outputs for GitHub Actions\n- **[actions-attest](./crates/actions-attest):** 🔏 Functions to write attestations for workflow artifacts\n\n## Installation\n\n![Cargo](https://img.shields.io/static/v1?style=for-the-badge\u0026message=Cargo\u0026color=e6b047\u0026logo=Rust\u0026logoColor=000000\u0026label=)\n\nYour reading the root monorepo readme. 😉 To install a specific `actions-*` package just click one of the links above ☝ and install that package. 🚀\n\nYou'll probably also want to [create an `action.yml` manifest and use configure-executable-action](https://github.com/jcbhmr/configure-executable-action) to manage the glue that will invoke your compiled executable.\n\n## Usage\n\n![Rust](https://img.shields.io/static/v1?style=for-the-badge\u0026message=Rust\u0026color=000000\u0026logo=Rust\u0026logoColor=FFFFFF\u0026label=)\n\nHere's an example that uses some (not all) of the `actions-*` packages in this monorepo listed above. Each package listed above ☝ also has its own readme with specific examples related to its specialty.\n\n```rs\nuse actions_core as core;\nuse actions_github as github;\nuse std::error::Error;\nuse chrono::prelude::*;\n\nfn main() {\n  let result = || -\u003e Result\u003c(), Box\u003cdyn Error\u003e\u003e {\n    // The `who-to-greet` input is defined in action metadata file\n    let who_to_greet = core::get_input_with_options(\"who-to-greet\", GetInputOptions {\n      required: true,\n      ...Default::default()\n    })?;\n    core::info!(\"Hello, {who_to_greet}!\");\n\n    // Get the current time and set it as an output\n    let time = Utc::now().to_string()\n    core::set_output(\"time\", time);\n\n    // Output the payload for debugging\n    let json = serde_json::to_string_pretty(github::context::payload)?;\n    core::info!(\"The event payload: {json}\");\n    Ok(())\n  }();\n  if let Err(error) = result {\n    core::set_failed!(\"{error}\");\n  }\n}\n```\n\n🔰 Based on the [hello-world-javascript-action](https://github.com/actions/hello-world-javascript-action) code example.\n\n💡 You'll probably want to use [configure-executable-action](https://github.com/jcbhmr/downlevel-executable-action) to manage the glue code to properly run your compiled executable.\n\n## Alternatives\n\nThere have been a few incomplete attempts to port the GitHub Actions actions/toolkit API to Rust before. [kjvalencik/actions](https://github.com/kjvalencik/actions) published [actions-toolkit](https://crates.io/crates/actions-toolkit) and [actions-core](https://crates.io/crates/actions-core). [romnn/action-rs](https://github.com/romnn/action-rs) published [action-artifact](https://crates.io/crates/action-artifact), [action-core](https://crates.io/crates/action-core), [action-derive](https://crates.io/crates/action-derive), [action-exec](https://crates.io/crates/action-exec), [action-github](https://crates.io/crates/action-github), [action-glob](https://crates.io/crates/action-glob), [action-http-client](https://crates.io/crates/action-http-client), and [action-io](https://crates.io/crates/action-io). Both of these projects appear to be stale that don't have much of an ecosystem surrounding them.\n\nThis actions-toolkit.rs project and the accompanying configure-executable-action configurator **aim to make Rust-based GitHub Actions a second-class citizen** -- an improvement on the current third-class status of relying Bash-based wrapper action configuration to call your Rust binary.\n\n:octocat: Interested in writing your GitHub Action another way? Check out the official guides on [Creating a compsite action](https://docs.github.com/en/actions/creating-actions/creating-a-composite-action), [Creating a Docker container action](https://docs.github.com/en/actions/creating-actions/creating-a-docker-container-action), and [Creating a JavaScript action](https://docs.github.com/en/actions/creating-actions/creating-a-javascript-action).\n\n## Development\n\n![Rust](https://img.shields.io/static/v1?style=for-the-badge\u0026message=Rust\u0026color=000000\u0026logo=Rust\u0026logoColor=FFFFFF\u0026label=)\n![Cargo](https://img.shields.io/static/v1?style=for-the-badge\u0026message=Cargo\u0026color=e6b047\u0026logo=Rust\u0026logoColor=000000\u0026label=)\n![Docs.rs](https://img.shields.io/static/v1?style=for-the-badge\u0026message=Docs.rs\u0026color=000000\u0026logo=Docs.rs\u0026logoColor=FFFFFF\u0026label=)\n\nThis project really tries to mirror the API and package surface of [actions/toolkit] as closely as is reasonable. **The goal is to replicate the well-known [@actions/core](https://www.npmjs.com/package/@actions/core) and friends API surface so that you only have to learn how to do things one way.** This has the convenient side effect of making existing documentation designed for JavaScript-based GitHub Actions \"work\" for Rust-based GitHub Actions.\n\nTo get started tinkering you can clone this repository and run `cargo test` to see everything happen! 🤩 There's no current root package so you'll need to specify a `--package \u003cpackage_name\u003e` or `-p \u003cpackage_name\u003e` argument to some `cargo` commands.\n\n~~This is a monorepo where each package independently manages its own version. This means that releasing the release \u0026 tag semantics are a bit wacky -- instead of a single tag like `v1.0.0` for each version of the entire project there's now N different tags, one for each `actions-*` package, each named according to `${package_name}-${package_version}` convention.~~ Nothing is currently published yet so this doesn't apply. I also want to do some research to see what the convention around monorepo tag naming is.\n\nThis repository was originally named \"toolkit.rs\" but since the organization/user name isn't actions-related ([@jcbhmr](https://github.com/jcbhmr) instead of [@actions](https://github.com/actions)) I added a prefix to clarify the name.\n\n🆘 I'm not a very proficient Rust programmer. If you see something that could be better, please tell me! ❤️ You can open an Issue, Pull Request, or even just comment on a commit. You'll probably be granted write access. 😉\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcbhmr%2Fgo-actions-toolkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcbhmr%2Fgo-actions-toolkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcbhmr%2Fgo-actions-toolkit/lists"}