update update

This commit is contained in:
Daylin Morgan 2024-07-18 10:17:59 -05:00
parent f8754b8105
commit 435d63b188
Signed by: daylin
GPG key ID: 950D13E9719334AD
3 changed files with 10 additions and 7 deletions

View file

@ -16,7 +16,7 @@ var updateCmd = &cobra.Command{
Short: "update and run nixos rebuild",
Run: func(cmd *cobra.Command, args []string) {
run := github.GetLastUpdateRun()
md, err := github.GetUpateSummary(run.GetID())
md, err := github.GetUpateSummary(run.GetID(), oizys.GetHost())
if err != nil {
log.Fatal(err)
}

View file

@ -60,10 +60,11 @@ func GetArtifacts(runID int64) (*github.ArtifactList, *github.Response) {
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)
for _, artifact := range artifactList.Artifacts {
if artifact.GetName() == "summary" {
if artifact.GetName() == artifactName {
return artifact
}
}
@ -71,8 +72,8 @@ func GetUpdateSummaryArtifact(runID int64) *github.Artifact {
return nil
}
func GetUpdateSummaryUrl(runID int64) *url.URL {
artifact := GetUpdateSummaryArtifact(runID)
func GetUpdateSummaryUrl(runID int64, host string) *url.URL {
artifact := GetUpdateSummaryArtifact(runID, host)
url, resp, err := client.Actions.DownloadArtifact(context.Background(), "daylinmorgan", "oizys", artifact.GetID(), 4)
if err != nil {
log.Fatal("failed to get update summary URL", "artifact", artifact.GetID(), "resp", resp)
@ -109,8 +110,8 @@ func GetLastUpdateRun() *github.WorkflowRun {
return run
}
func GetUpateSummary(runID int64) (string, error) {
url := GetUpdateSummaryUrl(runID)
func GetUpateSummary(runID int64, host string) (string, error) {
url := GetUpdateSummaryUrl(runID, host)
bytes := GetUpdateSummaryFromUrl(url)
md, err := ReadMarkdownFromZip(bytes, "summary.md")
return md, err

View file

@ -6,6 +6,7 @@ import (
"fmt"
"io/fs"
"oizys/internal/git"
// "oizys/internal/github"
"oizys/internal/ui"
"os"
@ -99,6 +100,7 @@ func SetHost(name string) {
}
}
func GetHost() string { return o.host }
func SetVerbose(v bool) {
o.verbose = v
}