Try gh-workflow (#41155)

Experimenting with not writing YAML by hand...

Release Notes:

- N/A
This commit is contained in:
Conrad Irwin
2025-10-27 13:39:01 -06:00
committed by GitHub
parent db0f7a8b23
commit 58f07ff709
13 changed files with 514 additions and 90 deletions
+33
View File
@@ -0,0 +1,33 @@
use anyhow::{Context, Result};
use clap::Parser;
use std::fs;
use std::path::Path;
mod runners;
mod steps;
mod vars;
mod workflows;
use workflows::*;
#[derive(Parser)]
pub struct GenerateWorkflowArgs {}
pub fn run_workflows(_: GenerateWorkflowArgs) -> Result<()> {
let dir = Path::new(".github/workflows");
let workflows = vec![("danger.yml", danger()), ("nix.yml", nix())];
fs::create_dir_all(dir)
.with_context(|| format!("Failed to create directory: {}", dir.display()))?;
for (filename, workflow) in workflows {
let content = workflow
.to_string()
.map_err(|e| anyhow::anyhow!("{}: {:?}", filename, e))?;
let content = format!("# generated `cargo xtask workflows`. Do not edit.\n{content}");
let file_path = dir.join(filename);
fs::write(&file_path, content)?;
}
Ok(())
}