-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Gitea should send tag webhook at release creation on UI #6027
Comments
Look also #5288 |
Any ideas or workarounds? I can look into it if this does not require a big change. I think this is useful. My goal is to have the non-devs in my department (like QA/PM and alike) can create the releases autonomously via the web interface. |
@techknowlogick any chance to get this into gitea? |
@typeless workaround is to create a tag in your local clone and push the tag to gitea. But it's a bit messy :) |
@xoxys However, as mentioned at #5288, Gitea already sends Release Event Hook. Not sure if there is any concern to send an extra webhook event. I need some suggestions before pushing my codes. Below is my draft codes (not finished yet): func createTag(gitRepo *git.Repository, rel *models.Release) error {
// Only actual create when publish.
if !rel.IsDraft {
if !gitRepo.IsTagExist(rel.TagName) {
commit, err := gitRepo.GetCommit(rel.Target)
if err != nil {
return fmt.Errorf("GetCommit: %v", err)
}
// Trim '--' prefix to prevent command line argument vulnerability.
rel.TagName = strings.TrimPrefix(rel.TagName, "--")
if err = gitRepo.CreateTag(rel.TagName, commit.ID.String()); err != nil {
if strings.Contains(err.Error(), "is not a valid tag name") {
return models.ErrInvalidTagName{
TagName: rel.TagName,
}
}
return err
}
rel.LowerTagName = strings.ToLower(rel.TagName)
// Prepare Webhook
if err := rel.LoadAttributes(); err != nil {
log.Error("LoadAttributes: %v", err)
} else {
var shaSum string
mode, _ := models.AccessLevel(rel.Publisher, rel.Repo)
apiRepo := rel.Repo.APIFormat(mode)
apiPusher := rel.Publisher.APIFormat()
shaSum, err = gitRepo.GetTagCommitID(rel.TagName)
if err != nil {
log.Error("GetTagCommitID[%s]: %v", rel.TagName, err)
}
if err = models.PrepareWebhooks(rel.Repo, models.HookEventPush, &api.CreatePayload{
Ref: git.TagPrefix + rel.TagName,
Sha: shaSum,
RefType: "tag",
Repo: apiRepo,
Sender: apiPusher,
}); err != nil {
log.Error("PrepareWebhooks: %v", err)
} else {
go models.HookQueue.Add(rel.Repo.ID)
}
}
}
commit, err := gitRepo.GetTagCommit(rel.TagName)
if err != nil {
return fmt.Errorf("GetTagCommit: %v", err)
}
rel.Sha1 = commit.ID.String()
rel.CreatedUnix = timeutil.TimeStamp(commit.Author.When.Unix())
rel.NumCommits, err = commit.CommitsCount()
if err != nil {
return fmt.Errorf("CommitsCount: %v", err)
}
} else {
rel.CreatedUnix = timeutil.TimeStampNow()
}
return nil
} |
@blueworrybear sending a push event in case a release was created is not the right solution. As mentinoned in the first post, a |
@xoxys In fact, publishing a I think send a |
[x]
):Description
If a release is created from the UI, gitea should send a tag webhook to trigger some CI Systems.
The text was updated successfully, but these errors were encountered: