dotenv_space/formats/
github.rs1use crate::core::converter::{ConvertOptions, Converter};
6use anyhow::Result;
7use std::collections::HashMap;
8
9pub struct GitHubActionsConverter {
10 pub separator: String,
11}
12
13impl Default for GitHubActionsConverter {
14 fn default() -> Self {
15 Self {
16 separator: "---".to_string(),
17 }
18 }
19}
20
21impl Converter for GitHubActionsConverter {
22 fn convert(&self, vars: &HashMap<String, String>, options: &ConvertOptions) -> Result<String> {
23 let filtered = options.filter_vars(vars);
24
25 let mut output = String::new();
26 output.push_str("Paste these into Settings → Secrets and variables → Actions:\n\n");
27
28 let count = filtered.len();
29 for (i, (k, v)) in filtered.iter().enumerate() {
30 let key = options.transform_key(k);
31 let value = options.transform_value(v);
32
33 output.push_str(&format!("Name: {}\n", key));
34 output.push_str(&format!("Value: {}\n", value));
35
36 if i < count - 1 {
37 output.push_str(&format!("{}\n", self.separator));
38 }
39 }
40
41 output.push_str(&format!(
42 "\n({} secrets total — paste each one individually)\n",
43 count
44 ));
45
46 Ok(output)
47 }
48
49 fn name(&self) -> &str {
50 "github-actions"
51 }
52
53 fn description(&self) -> &str {
54 "GitHub Actions secrets format (ready to paste)"
55 }
56}