actions_toolkit_sys/
core.rs

1use js_sys::{Function, JsString, Object, Promise};
2use wasm_bindgen::prelude::*;
3
4#[wasm_bindgen(module = "@actions/core")]
5extern {
6    #[wasm_bindgen(js_name = "issue")]
7    pub fn issue(name: &JsString, message: Option<&JsString>);
8
9    #[wasm_bindgen(js_name = "issueCommand")]
10    pub fn issue_command(command: &JsString, properties: &Object, message: &JsString);
11}
12
13/// Interface for getInput options
14#[wasm_bindgen]
15pub struct InputOptions {
16    /// Whether the input is required. If required and not present, will throw. Defaults
17    /// to false.
18    pub required: Option<bool>,
19}
20
21/// The code to exit an action
22#[wasm_bindgen]
23pub enum ExitCode {
24    /// A code indicating that the action was successful.
25    Success,
26    /// A code indicating that the action was a failure.
27    Failure,
28}
29
30#[wasm_bindgen(module = "@actions/core")]
31extern {
32    /// Sets env variable for this action and future actions in the job.
33    #[wasm_bindgen(js_name = "exportVariable")]
34    pub fn export_variable(name: &JsString, value: &JsString);
35
36    /// Exports the variable and registers a secret which will get masked from logs.
37    #[wasm_bindgen(js_name = "exportSecret")]
38    pub fn export_secret(name: &JsString, value: &JsString);
39
40    /// Prepends inputPath to the PATH (for this action and future actions).
41    #[wasm_bindgen(js_name = "addPath")]
42    pub fn add_path(path: &JsString);
43
44    /// Gets the value of an input. The value is also trimmed.
45    #[wasm_bindgen(js_name = "getInput")]
46    pub fn get_input(name: &JsString, options: Option<InputOptions>) -> JsString;
47
48    /// Sets the value of an output.
49    #[wasm_bindgen(js_name = "setOutput")]
50    pub fn set_output(name: &JsString, value: &JsString);
51
52    /// Sets the action status to failed. When the action exits it will be with an exit code of 1.
53    #[wasm_bindgen(js_name = "setFailed")]
54    pub fn set_failed(message: &JsString);
55
56    /// Writes debug message to user log.
57    #[wasm_bindgen]
58    pub fn debug(message: &JsString);
59
60    /// Adds an error issue.
61    #[wasm_bindgen]
62    pub fn error(message: &JsString);
63
64    /// Adds an warning issue.
65    #[wasm_bindgen]
66    pub fn warning(message: &JsString);
67
68    /// Writes info to log with console.log.
69    #[wasm_bindgen]
70    pub fn info(message: &JsString);
71
72    /// Begin an output group.
73    #[wasm_bindgen(js_name = "startGroup")]
74    pub fn start_group(name: &JsString);
75
76    /// End an output group.
77    #[wasm_bindgen(js_name = "endGroup")]
78    pub fn end_group();
79
80    /// Wrap an asynchronous function call in a group.
81    #[wasm_bindgen]
82    pub fn group(name: &JsString, fun: &Function) -> Promise;
83}