fix: adjust workflow link for pull_request_target workflow runs (#12734)
Fixes #12660, reported by @mahlzahn. ### Tests for Go changes - I added test coverage for Go changes... - [ ] in their respective `*_test.go` for unit tests. - [x] in the `tests/integration` directory if it involves interactions with a live Forgejo server. - I ran... - [ ] <s>`make pr-go` before pushing</s> because the OOM killer kills it before it does anything useful ### Documentation - [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change. - [x] I did not document these changes and I do not expect someone else to do it. ### Release notes - [x] This change will be noticed by a Forgejo user or admin (feature, bug fix, performance, etc.). I suggest to include a release note for this change. - [ ] This change is not visible to a Forgejo user or admin (refactor, dependency upgrade, etc.). I think there is no need to add a release note for this change. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/12734 Reviewed-by: Mathieu Fenniak <mfenniak@noreply.codeberg.org>
This commit is contained in:
committed by
Mathieu Fenniak
parent
2e8380025c
commit
19e1f58144
@@ -63,6 +63,15 @@ func View(ctx *app_context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
workflowDefinitionCommitSHA := job.Run.CommitSHA
|
||||
// if the trigger event is `pull_request_target`, then the definition of the workflow is taken
|
||||
// from the base branch instead of the commit the workflow is triggered on
|
||||
if job.Run.TriggerEvent == actions.GithubEventPullRequestTarget {
|
||||
if pullPayload, err := job.Run.GetPullRequestEventPayload(); err == nil && pullPayload.PullRequest != nil && pullPayload.PullRequest.Base != nil {
|
||||
workflowDefinitionCommitSHA = pullPayload.PullRequest.Base.Sha
|
||||
}
|
||||
}
|
||||
|
||||
workflowName := job.Run.WorkflowID
|
||||
|
||||
ctx.Data["RunIndex"] = runIndex
|
||||
@@ -72,7 +81,7 @@ func View(ctx *app_context.Context) {
|
||||
ctx.Data["AttemptNumber"] = attemptNumber
|
||||
ctx.Data["WorkflowName"] = workflowName
|
||||
ctx.Data["WorkflowURL"] = ctx.Repo.RepoLink + "/actions?workflow=" + workflowName
|
||||
ctx.Data["WorkflowSourceURL"] = ctx.Repo.RepoLink + "/src/commit/" + job.Run.CommitSHA + "/" + job.Run.WorkflowPath()
|
||||
ctx.Data["WorkflowSourceURL"] = ctx.Repo.RepoLink + "/src/commit/" + workflowDefinitionCommitSHA + "/" + job.Run.WorkflowPath()
|
||||
|
||||
viewResponse := getViewResponse(ctx, &ViewRequest{}, runIndex, jobIndex, attemptNumber)
|
||||
if ctx.Written() {
|
||||
|
||||
Reference in New Issue
Block a user