manager: Don't hardcode repository URL
This commit is contained in:
parent
d0c8389c3b
commit
24e834dde3
|
@ -34,12 +34,13 @@ async fn run() -> anyhow::Result<()> {
|
||||||
)
|
)
|
||||||
.context("Failed parsing GITHUB_SERVER_URL as a url")?;
|
.context("Failed parsing GITHUB_SERVER_URL as a url")?;
|
||||||
|
|
||||||
let mut repo_auth_url = server_url
|
let repo_url = server_url
|
||||||
.join(&format!(
|
.join(&format!(
|
||||||
"{}/{}",
|
"{}/{}",
|
||||||
meta.issue.repository.owner, meta.issue.repository.name
|
meta.issue.repository.owner, meta.issue.repository.name
|
||||||
))
|
))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
let mut repo_auth_url = repo_url.clone();
|
||||||
repo_auth_url.set_username("forgejo-actions").unwrap();
|
repo_auth_url.set_username("forgejo-actions").unwrap();
|
||||||
repo_auth_url.set_password(Some(&token)).unwrap();
|
repo_auth_url.set_password(Some(&token)).unwrap();
|
||||||
|
|
||||||
|
@ -71,7 +72,7 @@ async fn run() -> anyhow::Result<()> {
|
||||||
.await
|
.await
|
||||||
.context("Failed to render and publish the techtree to git")?;
|
.context("Failed to render and publish the techtree to git")?;
|
||||||
|
|
||||||
let mermaid = tree.to_mermaid();
|
let mermaid = tree.to_mermaid(&repo_url.to_string());
|
||||||
let wiki_text = format!(
|
let wiki_text = format!(
|
||||||
r##"This page is automatically updated to show the latest and greatest FAFO techtree:
|
r##"This page is automatically updated to show the latest and greatest FAFO techtree:
|
||||||
|
|
||||||
|
@ -124,7 +125,7 @@ async fn run() -> anyhow::Result<()> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let mermaid = subtree.to_mermaid();
|
let mermaid = subtree.to_mermaid(&repo_url.to_string());
|
||||||
|
|
||||||
let full_text = format!(
|
let full_text = format!(
|
||||||
r##"## Partial Techtree
|
r##"## Partial Techtree
|
||||||
|
|
|
@ -46,7 +46,12 @@ impl Element {
|
||||||
attributes.join(", ")
|
attributes.join(", ")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_mermaid_node(&self, index: ElementIndex, role: Option<SubtreeElementRole>) -> String {
|
fn to_mermaid_node(
|
||||||
|
&self,
|
||||||
|
index: ElementIndex,
|
||||||
|
role: Option<SubtreeElementRole>,
|
||||||
|
repo_url: &str,
|
||||||
|
) -> String {
|
||||||
let Element {
|
let Element {
|
||||||
issue_number,
|
issue_number,
|
||||||
description,
|
description,
|
||||||
|
@ -55,7 +60,7 @@ impl Element {
|
||||||
} = self;
|
} = self;
|
||||||
|
|
||||||
let label = format!(
|
let label = format!(
|
||||||
r##"<a href='/rahix/techtree-poc/issues/{issue_number}' target='_blank'>#{issue_number}</a> | {status}\n<i>{ty}</i>\n<b>{description}</b>"##
|
r##"<a href='{repo_url}/issues/{issue_number}' target='_blank'>#{issue_number}</a> | {status}\n<i>{ty}</i>\n<b>{description}</b>"##
|
||||||
);
|
);
|
||||||
|
|
||||||
let class = match (role, status) {
|
let class = match (role, status) {
|
||||||
|
@ -163,13 +168,13 @@ impl Tree {
|
||||||
format!("{:?}", dot)
|
format!("{:?}", dot)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_mermaid(&self) -> String {
|
pub fn to_mermaid(&self, repo_url: &str) -> String {
|
||||||
let mut mermaid = String::new();
|
let mut mermaid = String::new();
|
||||||
mermaid.push_str("flowchart BT\n");
|
mermaid.push_str("flowchart BT\n");
|
||||||
mermaid.push_str(&mermaid_classes());
|
mermaid.push_str(&mermaid_classes());
|
||||||
|
|
||||||
for index in self.graph.node_indices() {
|
for index in self.graph.node_indices() {
|
||||||
mermaid.push_str(&self.graph[index].to_mermaid_node(index, None));
|
mermaid.push_str(&self.graph[index].to_mermaid_node(index, None, repo_url));
|
||||||
mermaid.push_str("\n");
|
mermaid.push_str("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,14 +292,18 @@ impl<'a> Subtree<'a> {
|
||||||
format!("{:?}", dot)
|
format!("{:?}", dot)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_mermaid(&self) -> String {
|
pub fn to_mermaid(&self, repo_url: &str) -> String {
|
||||||
let mut mermaid = String::new();
|
let mut mermaid = String::new();
|
||||||
mermaid.push_str("flowchart BT\n");
|
mermaid.push_str("flowchart BT\n");
|
||||||
mermaid.push_str(&mermaid_classes());
|
mermaid.push_str(&mermaid_classes());
|
||||||
|
|
||||||
for index in self.graph.node_indices() {
|
for index in self.graph.node_indices() {
|
||||||
let node = &self.graph[index];
|
let node = &self.graph[index];
|
||||||
mermaid.push_str(&node.element.to_mermaid_node(index, Some(node.role)));
|
mermaid.push_str(
|
||||||
|
&node
|
||||||
|
.element
|
||||||
|
.to_mermaid_node(index, Some(node.role), repo_url),
|
||||||
|
);
|
||||||
mermaid.push_str("\n");
|
mermaid.push_str("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue