mirror of
https://github.com/daylinmorgan/oizys.git
synced 2024-12-22 18:30:43 -06:00
update update
This commit is contained in:
parent
f8754b8105
commit
435d63b188
3 changed files with 10 additions and 7 deletions
|
@ -16,7 +16,7 @@ var updateCmd = &cobra.Command{
|
||||||
Short: "update and run nixos rebuild",
|
Short: "update and run nixos rebuild",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
run := github.GetLastUpdateRun()
|
run := github.GetLastUpdateRun()
|
||||||
md, err := github.GetUpateSummary(run.GetID())
|
md, err := github.GetUpateSummary(run.GetID(), oizys.GetHost())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,10 +60,11 @@ func GetArtifacts(runID int64) (*github.ArtifactList, *github.Response) {
|
||||||
return artifactList, resp
|
return artifactList, resp
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetUpdateSummaryArtifact(runID int64) *github.Artifact {
|
func GetUpdateSummaryArtifact(runID int64, host string) *github.Artifact {
|
||||||
|
artifactName := fmt.Sprintf("%s-summary", host)
|
||||||
artifactList, _ := GetArtifacts(runID)
|
artifactList, _ := GetArtifacts(runID)
|
||||||
for _, artifact := range artifactList.Artifacts {
|
for _, artifact := range artifactList.Artifacts {
|
||||||
if artifact.GetName() == "summary" {
|
if artifact.GetName() == artifactName {
|
||||||
return artifact
|
return artifact
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,8 +72,8 @@ func GetUpdateSummaryArtifact(runID int64) *github.Artifact {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetUpdateSummaryUrl(runID int64) *url.URL {
|
func GetUpdateSummaryUrl(runID int64, host string) *url.URL {
|
||||||
artifact := GetUpdateSummaryArtifact(runID)
|
artifact := GetUpdateSummaryArtifact(runID, host)
|
||||||
url, resp, err := client.Actions.DownloadArtifact(context.Background(), "daylinmorgan", "oizys", artifact.GetID(), 4)
|
url, resp, err := client.Actions.DownloadArtifact(context.Background(), "daylinmorgan", "oizys", artifact.GetID(), 4)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("failed to get update summary URL", "artifact", artifact.GetID(), "resp", resp)
|
log.Fatal("failed to get update summary URL", "artifact", artifact.GetID(), "resp", resp)
|
||||||
|
@ -109,8 +110,8 @@ func GetLastUpdateRun() *github.WorkflowRun {
|
||||||
return run
|
return run
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetUpateSummary(runID int64) (string, error) {
|
func GetUpateSummary(runID int64, host string) (string, error) {
|
||||||
url := GetUpdateSummaryUrl(runID)
|
url := GetUpdateSummaryUrl(runID, host)
|
||||||
bytes := GetUpdateSummaryFromUrl(url)
|
bytes := GetUpdateSummaryFromUrl(url)
|
||||||
md, err := ReadMarkdownFromZip(bytes, "summary.md")
|
md, err := ReadMarkdownFromZip(bytes, "summary.md")
|
||||||
return md, err
|
return md, err
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"oizys/internal/git"
|
"oizys/internal/git"
|
||||||
|
|
||||||
// "oizys/internal/github"
|
// "oizys/internal/github"
|
||||||
"oizys/internal/ui"
|
"oizys/internal/ui"
|
||||||
"os"
|
"os"
|
||||||
|
@ -99,6 +100,7 @@ func SetHost(name string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetHost() string { return o.host }
|
||||||
func SetVerbose(v bool) {
|
func SetVerbose(v bool) {
|
||||||
o.verbose = v
|
o.verbose = v
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue