Skip to content

Commit 1e79fcc

Browse files
committed
add action run url to footer
1 parent e2a73e8 commit 1e79fcc

4 files changed

Lines changed: 22 additions & 5 deletions

File tree

internal/ci/actions/createOrUpdatePR.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ func GeneratePRFromReports(inputDir string) (*prdescription.Output, *versioning.
9393
LintingReportURL: lintingReportURL,
9494
ChangesReportURL: changesReportURL,
9595
ManualBump: manualBump,
96+
ActionRunURL: environment.GetActionRunURL(environment.GetRepo()),
9697
}
9798

9899
output, err := prdescription.Generate(input)

internal/ci/environment/environment.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,15 @@ func GetGithubServerURL() string {
365365
return os.Getenv("GITHUB_SERVER_URL")
366366
}
367367

368+
func GetActionRunURL(repo string) string {
369+
serverURL := os.Getenv("GITHUB_SERVER_URL")
370+
runID := os.Getenv("GITHUB_RUN_ID")
371+
if serverURL == "" || repo == "" || runID == "" {
372+
return ""
373+
}
374+
return fmt.Sprintf("%s/%s/actions/runs/%s", serverURL, repo, runID)
375+
}
376+
368377
func GetGithubOIDCRequestURL() string {
369378
return os.Getenv("ACTIONS_ID_TOKEN_REQUEST_URL")
370379
}

internal/ci/telemetry/telemetry.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ func EnrichEventWithEnvironmentVariables(event *shared.CliEvent) {
6868
event.GhActionOrganization = &ghActionOrg
6969
repo := strings.TrimPrefix(ghActionRepoOrg, ghActionOrg+"/")
7070
event.GhActionRepository = &repo
71-
runLink := fmt.Sprintf("%s/%s/actions/runs/%s", os.Getenv("GITHUB_SERVER_URL"), ghActionRepoOrg, os.Getenv("GITHUB_RUN_ID"))
72-
event.GhActionRunLink = &runLink
71+
if runLink := environment.GetActionRunURL(ghActionRepoOrg); runLink != "" {
72+
event.GhActionRunLink = &runLink
73+
}
7374

7475
ghActionVersion := os.Getenv("GH_ACTION_VERSION")
7576
if ghActionVersion != "" {

internal/prdescription/prdescription.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type Input struct {
3131
// Version information
3232
SpeakeasyVersion string `json:"speakeasy_version,omitempty"`
3333
ManualBump bool `json:"manual_bump,omitempty"`
34+
ActionRunURL string `json:"action_run_url,omitempty"`
3435

3536
// Version report data (from SPEAKEASY_VERSION_REPORT_LOCATION)
3637
VersionReport *versioning.MergedVersionReport `json:"version_report,omitempty"`
@@ -132,9 +133,14 @@ func buildBody(input Input) string {
132133
body.WriteString(stripANSICodes(markdownSection))
133134
}
134135

135-
// Footer with CLI version
136-
if !input.SourceGeneration && input.SpeakeasyVersion != "" {
137-
body.WriteString(fmt.Sprintf("\nBased on [Speakeasy CLI](https://github.com/speakeasy-api/speakeasy) %s\n", input.SpeakeasyVersion))
136+
// Footer
137+
if !input.SourceGeneration {
138+
if input.SpeakeasyVersion != "" {
139+
body.WriteString(fmt.Sprintf("\nBased on [Speakeasy CLI](https://github.com/speakeasy-api/speakeasy) %s\n", input.SpeakeasyVersion))
140+
}
141+
if input.ActionRunURL != "" {
142+
body.WriteString(fmt.Sprintf("\nLast updated by [Speakeasy workflow](%s)\n", input.ActionRunURL))
143+
}
138144
}
139145

140146
return body.String()

0 commit comments

Comments
 (0)