Skip to content

Commit 9f560d4

Browse files
lunnywxiaoguang
andauthored
Make actions URL in commit status webhooks absolute (#33620)
Gitea Actions generated target url doesn't contain host and port. So we need to include them for external webhook visiting. Fix #33603 --------- Co-authored-by: wxiaoguang <[email protected]>
1 parent 15e020e commit 9f560d4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Diff for: services/webhook/notifier.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
repo_model "code.gitea.io/gitea/models/repo"
1616
user_model "code.gitea.io/gitea/models/user"
1717
"code.gitea.io/gitea/modules/git"
18+
"code.gitea.io/gitea/modules/httplib"
1819
"code.gitea.io/gitea/modules/log"
1920
"code.gitea.io/gitea/modules/repository"
2021
"code.gitea.io/gitea/modules/setting"
@@ -871,14 +872,19 @@ func (m *webhookNotifier) CreateCommitStatus(ctx context.Context, repo *repo_mod
871872
return
872873
}
873874

875+
// as a webhook url, target should be an absolute url. But for internal actions target url
876+
// the target url is a url path with no host and port to make it easy to be visited
877+
// from multiple hosts. So we need to convert it to an absolute url here.
878+
target := httplib.MakeAbsoluteURL(ctx, status.TargetURL)
879+
874880
payload := api.CommitStatusPayload{
875881
Context: status.Context,
876882
CreatedAt: status.CreatedUnix.AsTime().UTC(),
877883
Description: status.Description,
878884
ID: status.ID,
879885
SHA: commit.Sha1,
880886
State: status.State.String(),
881-
TargetURL: status.TargetURL,
887+
TargetURL: target,
882888

883889
Commit: apiCommit,
884890
Repo: convert.ToRepo(ctx, repo, access_model.Permission{AccessMode: perm.AccessModeOwner}),

0 commit comments

Comments
 (0)