Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
gitlab
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
maubot
gitlab
Commits
04e8195b
Commit
04e8195b
authored
7 years ago
by
Tulir Asokan
Browse files
Options
Downloads
Patches
Plain Diff
Add support for tag push events (ref #1)
parent
96d90dfb
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+1
-1
1 addition, 1 deletion
README.md
gitlab-webhook.go
+17
-0
17 additions, 0 deletions
gitlab-webhook.go
with
18 additions
and
1 deletion
README.md
+
1
−
1
View file @
04e8195b
...
...
@@ -10,7 +10,7 @@ A Gitlab bot for Matrix. It uses
*
[X] Issues/merge requests
*
[X] Comments
*
[X] Push events
*
[
] Tag creation
*
[
x
] Tag creation
*
[ ] Pipeline events
*
[ ] Wiki page edits
*
[x] Log in to GitLab accounts (per-user)
...
...
This diff is collapsed.
Click to expand it.
gitlab-webhook.go
+
17
−
0
View file @
04e8195b
...
...
@@ -42,6 +42,7 @@ func addRoomToHeaders(handler http.Handler) http.Handler {
func
startWebhook
()
func
()
{
hook
:=
gitlab
.
New
(
&
gitlab
.
Config
{
Secret
:
config
.
Webhook
.
Secret
})
hook
.
RegisterEvents
(
handlePushEvent
,
gitlab
.
PushEvents
)
hook
.
RegisterEvents
(
handleTagEvent
,
gitlab
.
TagEvents
)
hook
.
RegisterEvents
(
handleIssueEvent
,
gitlab
.
IssuesEvents
)
hook
.
RegisterEvents
(
handleMergeRequestEvent
,
gitlab
.
MergeRequestEvents
)
hook
.
RegisterEvents
(
handleCommentEvent
,
gitlab
.
CommentEvents
)
...
...
@@ -123,6 +124,22 @@ func handlePushEvent(payload interface{}, header webhooks.Header) {
}
}
func
handleTagEvent
(
payload
interface
{},
header
webhooks
.
Header
)
{
data
:=
payload
.
(
gitlab
.
TagEventPayload
)
if
data
.
ObjectKind
!=
"tag_push"
{
return
}
roomID
:=
header
[
"X-Room-Id"
][
0
]
room
:=
mxbot
.
GetRoom
(
roomID
)
tag
:=
strings
.
TrimPrefix
(
data
.
Ref
,
"refs/tags/"
)
room
.
SendfHTML
(
"[%[1]s/%[2]s] %[3]s created tag <a href='%[4]s/tags/%[5]s'>%[5]s</a>"
,
data
.
Project
.
Namespace
,
data
.
Project
.
Name
,
data
.
UserName
,
data
.
Project
.
WebURL
,
tag
)
}
func
handleIssueEvent
(
payload
interface
{},
header
webhooks
.
Header
)
{
data
:=
payload
.
(
gitlab
.
IssueEventPayload
)
roomID
:=
header
[
"X-Room-Id"
][
0
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment