1 个不稳定版本
0.1.0 | 2024年3月21日 |
---|
#11 在 #outputs
35KB
735 行
actions-core
✅ 获取输入、设置输出和其他基本操作以用于 GitHub Actions
|
👀 查找更多 GitHub Actions 包?请查看 actions-toolkit.rs 项目。
安装
cargo add actions-core2
⚠️ 在您的 Rust 代码中使用 use actions_core
。包名与包名不同。
使用方法
use actions_core as core;
use std::error::Error;
fn main() {
let result = || -> Result<(), Box<dyn Error>> {
let name = core::get_input_with_options("name", core::InputOptions {
required: true,
..Default::default()
})?;
let favorite_color = core::get_input("favorite-color")?;
core::info!("Hello {name}!");
core::set_output("message", "Wow! Rust is awesome!");
Ok(())
}();
if let Err(error) = result {
core::set_failed!("{error}");
}
}
🤔 如何在 action.yml
中实际使用生成的可执行文件?请查看 configure-executable-action!
开发
该项目是 actions-toolkit.rs 项目的一部分。
🆘 我不是一名非常熟练的 Rust 程序员。如果您看到可以改进的地方,请告诉我! ❤️ 您可以打开 Issue、Pull Request,甚至只是对提交进行评论。您可能会被授予写入权限。 😉
待办事项列表
- 复制来自 @actions/core 的公共 API 表面。包括假字符串行为。
- 决定使用
get_input("name", Some(...))
与get_input_with_options("name", ...)
与get_input!("name", ...)
的区别。需要查找现有的 Rust 项目以了解惯例。 - 找出何时使用
AsRef<str>
、&str
、String
、Cow<str>
等。作为参数和返回类型。我需要对现有的 Rust 项目进行一些调查。 - 将此包发布到 crates.io。这也包括设置 GitHub Actions 以在每次适当的单仓库发布上发布包。
- 将此内容复制到包的 README。
- 添加示例。至少两个。
- 为公共API添加文档。不仅仅是“get_input()获取输入”。
依赖项
~4–16MB
~233K SLoC