Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/glensc/gitlab-webhook-listener-bot
Gitlab WebHook Listener Bot
https://github.com/glensc/gitlab-webhook-listener-bot
git gitlab hook listener webhook
Last synced: about 2 months ago
JSON representation
Gitlab WebHook Listener Bot
- Host: GitHub
- URL: https://github.com/glensc/gitlab-webhook-listener-bot
- Owner: glensc
- License: mit
- Created: 2023-07-30T18:42:49.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-13T16:35:07.000Z (9 months ago)
- Last Synced: 2024-04-14T10:15:43.437Z (9 months ago)
- Topics: git, gitlab, hook, listener, webhook
- Language: TypeScript
- Homepage:
- Size: 438 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Gitlab WebHook Listener Bot
This project will listen for GitLab webhook events,
and do actions based on context.- https://docs.gitlab.com/ee/user/project/integrations/webhooks.html
- https://docs.gitlab.com/ee/user/project/integrations/webhook_events.htmlThe project acts as a building block for you to create your own handlers.
## Example
This will execute code to re-run renovate bot if the `[x]` check is checked.
```ts
import { main, logger, MergeRequestHandler } from "gitlab-webhook-listener-bot";class RenovateRebase extends MergeRequestHandler {
public async handle(payload: MergeRequestPayload): Promise {
this.logger.debug("Renovate bot wants rebase");
// TODO: create pipeline
// code here to do the actual action
}/**
* Must be an opened mr whose status is updated
* and branch is renovate branch
* and rebase checkbox is checked.
*/
public isValid(payload: MergeRequestPayload): boolean {
const {
object_attributes: {
source_branch,
action,
state,
},
changes: {
description,
},
} = payload;return (
state === "opened" &&
action === "update" &&
source_branch.startsWith("renovate/") &&
(description?.current || "").includes("[x] ")
);
}
}main({
logger,
handlers: [
new RenovateRebase(logger),
],
});
```## Demo
There's standalone project that you can copy and start your own project from it:
- [demo/](demo)## Similar projects
- https://github.com/kolomiichenko/gitlab-webhooker - write callbacks as handlers. unmaintained.
- https://github.com/nanoy42/gitlab-webhook-telegram - sends events to telegram.
- https://github.com/glensc/gitlab-registry-cleanup-hook - deletes related docker images on merge
- https://gidgetlab.readthedocs.io - a similar project providing a Python framework for GitLab API and webhooks