Skip to content

File tree

5 files changed

+46
-18
lines changed

5 files changed

+46
-18
lines changed

models/actions/run.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ func (run *ActionRun) Link() string {
7474
return fmt.Sprintf("%s/actions/runs/%d", run.Repo.Link(), run.Index)
7575
}
7676

77+
func (run *ActionRun) WorkflowLink() string {
78+
if run.Repo == nil {
79+
return ""
80+
}
81+
return fmt.Sprintf("%s/actions/?workflow=%s", run.Repo.Link(), run.WorkflowID)
82+
}
83+
7784
// RefLink return the url of run's ref
7885
func (run *ActionRun) RefLink() string {
7986
refName := git.RefName(run.Ref)
@@ -156,6 +163,10 @@ func (run *ActionRun) GetPullRequestEventPayload() (*api.PullRequestPayload, err
156163
return nil, fmt.Errorf("event %s is not a pull request event", run.Event)
157164
}
158165

166+
func (run *ActionRun) IsSchedule() bool {
167+
return run.ScheduleID > 0
168+
}
169+
159170
func updateRepoRunsNumbers(ctx context.Context, repo *repo_model.Repository) error {
160171
_, err := db.GetEngine(ctx).ID(repo.ID).
161172
SetExpr("num_action_runs",

routers/web/repo/actions/view.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ type ViewResponse struct {
6767
CanRerun bool `json:"canRerun"`
6868
CanDeleteArtifact bool `json:"canDeleteArtifact"`
6969
Done bool `json:"done"`
70+
WorkflowID string `json:"workflowID"`
71+
WorkflowLink string `json:"workflowLink"`
72+
IsSchedule bool `json:"isSchedule"`
7073
Jobs []*ViewJob `json:"jobs"`
7174
Commit ViewCommit `json:"commit"`
7275
} `json:"run"`
@@ -90,12 +93,10 @@ type ViewJob struct {
9093
}
9194

9295
type ViewCommit struct {
93-
LocaleCommit string `json:"localeCommit"`
94-
LocalePushedBy string `json:"localePushedBy"`
95-
ShortSha string `json:"shortSHA"`
96-
Link string `json:"link"`
97-
Pusher ViewUser `json:"pusher"`
98-
Branch ViewBranch `json:"branch"`
96+
ShortSha string `json:"shortSHA"`
97+
Link string `json:"link"`
98+
Pusher ViewUser `json:"pusher"`
99+
Branch ViewBranch `json:"branch"`
99100
}
100101

101102
type ViewUser struct {
@@ -151,6 +152,9 @@ func ViewPost(ctx *context_module.Context) {
151152
resp.State.Run.CanRerun = run.Status.IsDone() && ctx.Repo.CanWrite(unit.TypeActions)
152153
resp.State.Run.CanDeleteArtifact = run.Status.IsDone() && ctx.Repo.CanWrite(unit.TypeActions)
153154
resp.State.Run.Done = run.Status.IsDone()
155+
resp.State.Run.WorkflowID = run.WorkflowID
156+
resp.State.Run.WorkflowLink = run.WorkflowLink()
157+
resp.State.Run.IsSchedule = run.IsSchedule()
154158
resp.State.Run.Jobs = make([]*ViewJob, 0, len(jobs)) // marshal to '[]' instead fo 'null' in json
155159
resp.State.Run.Status = run.Status.String()
156160
for _, v := range jobs {
@@ -172,12 +176,10 @@ func ViewPost(ctx *context_module.Context) {
172176
Link: run.RefLink(),
173177
}
174178
resp.State.Run.Commit = ViewCommit{
175-
LocaleCommit: ctx.Locale.TrString("actions.runs.commit"),
176-
LocalePushedBy: ctx.Locale.TrString("actions.runs.pushed_by"),
177-
ShortSha: base.ShortSha(run.CommitSHA),
178-
Link: fmt.Sprintf("%s/commit/%s", run.Repo.Link(), run.CommitSHA),
179-
Pusher: pusher,
180-
Branch: branch,
179+
ShortSha: base.ShortSha(run.CommitSHA),
180+
Link: fmt.Sprintf("%s/commit/%s", run.Repo.Link(), run.CommitSHA),
181+
Pusher: pusher,
182+
Branch: branch,
181183
}
182184

183185
var task *actions_model.ActionTask

templates/repo/actions/runs_list.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
{{if .Title}}{{.Title}}{{else}}{{ctx.Locale.Tr "actions.runs.empty_commit_message"}}{{end}}
1616
</a>
1717
<div class="flex-item-body">
18-
<b>{{if not $.CurWorkflow}}{{.WorkflowID}} {{end}}#{{.Index}}</b>:
18+
<span><b>{{if not $.CurWorkflow}}{{.WorkflowID}} {{end}}#{{.Index}}</b>:</span>
1919
{{- if .ScheduleID -}}
2020
{{ctx.Locale.Tr "actions.runs.scheduled"}}
2121
{{- else -}}

templates/repo/actions/view.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
data-locale-cancel="{{ctx.Locale.Tr "cancel"}}"
1111
data-locale-rerun="{{ctx.Locale.Tr "rerun"}}"
1212
data-locale-rerun-all="{{ctx.Locale.Tr "rerun_all"}}"
13+
data-locale-runs-scheduled="{{ctx.Locale.Tr "actions.runs.scheduled"}}"
14+
data-locale-runs-commit="{{ctx.Locale.Tr "actions.runs.commit"}}"
15+
data-locale-runs-pushed-by="{{ctx.Locale.Tr "actions.runs.pushed_by"}}"
1316
data-locale-status-unknown="{{ctx.Locale.Tr "actions.status.unknown"}}"
1417
data-locale-status-waiting="{{ctx.Locale.Tr "actions.status.waiting"}}"
1518
data-locale-status-running="{{ctx.Locale.Tr "actions.status.running"}}"

web_src/js/components/RepoActionView.vue

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ const sfc = {
4444
canApprove: false,
4545
canRerun: false,
4646
done: false,
47+
workflowID: '',
48+
workflowLink: '',
49+
isSchedule: false,
4750
jobs: [
4851
// {
4952
// id: 0,
@@ -338,10 +341,13 @@ export function initRepositoryActionView() {
338341
approve: el.getAttribute('data-locale-approve'),
339342
cancel: el.getAttribute('data-locale-cancel'),
340343
rerun: el.getAttribute('data-locale-rerun'),
344+
rerun_all: el.getAttribute('data-locale-rerun-all'),
345+
scheduled: el.getAttribute('data-locale-runs-scheduled'),
346+
commit: el.getAttribute('data-locale-runs-commit'),
347+
pushedBy: el.getAttribute('data-locale-runs-pushed-by'),
341348
artifactsTitle: el.getAttribute('data-locale-artifacts-title'),
342349
areYouSure: el.getAttribute('data-locale-are-you-sure'),
343350
confirmDeleteArtifact: el.getAttribute('data-locale-confirm-delete-artifact'),
344-
rerun_all: el.getAttribute('data-locale-rerun-all'),
345351
showTimeStamps: el.getAttribute('data-locale-show-timestamps'),
346352
showLogSeconds: el.getAttribute('data-locale-show-log-seconds'),
347353
showFullScreen: el.getAttribute('data-locale-show-full-screen'),
@@ -382,10 +388,16 @@ export function initRepositoryActionView() {
382388
</button>
383389
</div>
384390
<div class="action-commit-summary">
385-
{{ run.commit.localeCommit }}
386-
<a class="muted" :href="run.commit.link">{{ run.commit.shortSHA }}</a>
387-
{{ run.commit.localePushedBy }}
388-
<a class="muted" :href="run.commit.pusher.link">{{ run.commit.pusher.displayName }}</a>
391+
<span><a class="muted" :href="run.workflowLink"><b>{{ run.workflowID }}</b></a>:</span>
392+
<template v-if="run.isSchedule">
393+
{{ locale.scheduled }}
394+
</template>
395+
<template v-else>
396+
{{ locale.commit }}
397+
<a class="muted" :href="run.commit.link">{{ run.commit.shortSHA }}</a>
398+
{{ locale.pushedBy }}
399+
<a class="muted" :href="run.commit.pusher.link">{{ run.commit.pusher.displayName }}</a>
400+
</template>
389401
<span class="ui label tw-max-w-full" v-if="run.commit.shortSHA">
390402
<a class="gt-ellipsis" :href="run.commit.branch.link">{{ run.commit.branch.name }}</a>
391403
</span>

0 commit comments

Comments
 (0)