Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make actions URL in commit status webhooks absolute (#33620) #33632

Merged
merged 1 commit into from
Feb 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion services/webhook/notifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/httplib"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/setting"
Expand Down Expand Up @@ -875,14 +876,19 @@ func (m *webhookNotifier) CreateCommitStatus(ctx context.Context, repo *repo_mod
return
}

// as a webhook url, target should be an absolute url. But for internal actions target url
// the target url is a url path with no host and port to make it easy to be visited
// from multiple hosts. So we need to convert it to an absolute url here.
target := httplib.MakeAbsoluteURL(ctx, status.TargetURL)

payload := api.CommitStatusPayload{
Context: status.Context,
CreatedAt: status.CreatedUnix.AsTime().UTC(),
Description: status.Description,
ID: status.ID,
SHA: commit.Sha1,
State: status.State.String(),
TargetURL: status.TargetURL,
TargetURL: target,

Commit: apiCommit,
Repo: convert.ToRepo(ctx, repo, access_model.Permission{AccessMode: perm.AccessModeOwner}),
Expand Down
Loading