26 lines
850 B
Rust
26 lines
850 B
Rust
|
//
|
||
|
use crate::model::Config;
|
||
|
use crate::patterns::{issue_pattern, marker_pattern};
|
||
|
use anyhow::{Context, Result};
|
||
|
|
||
|
pub fn init_config() -> Result<Config, anyhow::Error> {
|
||
|
let config = Config::builder()
|
||
|
.fs(kxio::fs::new(
|
||
|
std::env::var("GITHUB_WORKSPACE")
|
||
|
.context("GITHUB_WORKSPACE")?
|
||
|
.into(),
|
||
|
))
|
||
|
.repo(std::env::var("GITHUB_REPOSITORY").context("GITHUB_REPOSITORY")?)
|
||
|
.server(std::env::var("GITHUB_SERVER_URL").context("GITHUB_SERVER_URL")?)
|
||
|
.prefix_pattern(marker_pattern()?)
|
||
|
.issue_pattern(issue_pattern()?)
|
||
|
.maybe_auth_token(std::env::var("REPO_TOKEN").ok())
|
||
|
.build();
|
||
|
|
||
|
println!("Repo: {}", config.repo());
|
||
|
println!("Prefix: {}", config.prefix_pattern());
|
||
|
println!("Issues: {}", config.issue_pattern());
|
||
|
|
||
|
Ok(config)
|
||
|
}
|