1use actions_rs::{Annotation, Cell, Summary, env, log, output};
12
13fn main() {
14 log::info(format!(
15 "in GitHub Actions: {} | CI: {} | step-debug: {}",
16 env::is_github_actions(),
17 env::is_ci(),
18 log::is_debug()
19 ));
20
21 let ctx = actions_rs::Context::new();
22 log::info(format!(
23 "repo={:?} ref={:?} sha={:?}",
24 ctx.repository(),
25 ctx.ref_name(),
26 ctx.sha()
27 ));
28
29 Annotation::new()
32 .file("src/lib.rs")
33 .line(10)
34 .end_line(12)
35 .title("demo")
36 .warning("heads up: this span looks suspicious");
37
38 Annotation::new()
40 .title("type: mismatch, really")
41 .error("line one\nline two");
42
43 let total = log::group("expensive step", || {
44 log::info("...working...");
45 2 + 2
46 });
47 log::info(format!("group returned {total}"));
48
49 actions_rs::warning!("formatted macro: {} items left", 7);
50
51 output::set_output("answer", 42).expect("set_output");
52 match output::export_var("DEMO_FLAG", true) {
53 Ok(()) => {}
54 Err(actions_rs::Error::UnavailableFileCommand {
55 var: "GITHUB_ENV", ..
56 }) => {
57 log::info("GITHUB_ENV unset; skipping export_var in local demo");
58 }
59 Err(err) => panic!("export_var: {err}"),
60 }
61
62 let mut summary = Summary::new();
63 summary
64 .heading("Demo Report", 2)
65 .raw("Built by the `demo` example.", true)
66 .table([
67 vec![Cell::header("Check"), Cell::header("Result")],
68 vec![Cell::new("clippy"), Cell::new("pass")],
69 vec![Cell::new("tests"), Cell::new("36 pass")],
70 ])
71 .code_block("cargo test", Some("sh"));
72 summary.write().expect("write summary");
73 log::info("summary written (if GITHUB_STEP_SUMMARY was set)");
74}