AnyCiCd
anyCiCD is a gitHub / giTea / Gogs webhook server/runner.Listens for any event from those platforms , pointed in public ip/url , which anyCiCD is currently running.When an event triggers , will execute shell script you specified..
Install / Use
/learn @Kos-M/AnyCiCdREADME
anyCiCd
anyCiCd is a lightweight and flexible CI/CD webhook handler designed to integrate with various Git platforms (e.g., GitHub, GitLab, Bitbucket) and trigger custom scripts based on repository events. It allows you to automate tasks like deployments, testing, and notifications by executing shell scripts in response to specific webhook payloads.
Features
- Webhook Listener: Listens for incoming webhook events from Git platforms.
- Event-driven Script Execution: Triggers predefined shell scripts based on the type of repository event (e.g., push, pull request, issue).
- Signature Verification: (To be implemented/verified) Ensures the authenticity of incoming webhooks.
- Customizable Actions: Easily configure which scripts to run for different events.
Getting Started
Prerequisites
- Node.js (LTS version recommended)
- npm or Yarn
Installation
-
Clone the repository:
git clone https://github.com/Kos-M/anyCiCd.git cd anyCiCd -
Install dependencies:
npm install # or yarn install -
Configure Environment Variables:
Create a
.envfile in the root directory by copyingsample.envand fill in the necessary values.cp sample.env .envEdit
.env:PORT=3000 GITHUB_WEBHOOK_SECRET=your_github_webhook_secret # Add other secrets/configurations as neededRepository Event Script Configuration: For each repository event, you can define an environment variable pointing to a shell script that will be executed when the corresponding webhook is received. The full JSON payload of the webhook will be passed as the first argument to your script.
Example:
repo_push=./exec/on_repo_push.sh repo_create=./exec/on_repo_create.sh # ... and so on for other repository eventsIssue Event Script Configuration: Similar to repository events, you can define environment variables for issue events. The
actionfield in the webhook payload determines which script is executed.Example:
issues_open=./exec/on_issue_open.sh issues_comment_create=./exec/on_issue_comment_create.sh # ... and so on for other issue eventsPull Request Event Script Configuration: Currently, there is a single endpoint for all pull request events. You can define an environment variable to execute a script for any pull request webhook. The
actionfield in the webhook payload will indicate the specific pull request event.Example:
pull_request_event=./exec/on_pull_request.sh -
Build the TypeScript files:
npm run build # or yarn build -
Run the application:
npm start # or yarn startThe server will start on the configured
PORT(default: 3000).
API Reference
All API endpoints expect POST requests with a JSON payload and require signature verification using the X-Hub-Signature header. The X-GitHub-Event header (or equivalent for other Git platforms) is used to identify the event type.
Repository Events
These endpoints handle various repository-related events. The full webhook payload is passed as an argument to the configured script.
POST /api/repo/{event_type}
Endpoints:
-
/api/repo/push- Description: Triggered when a push is made to the repository.
- Environment Variable:
repo_push - Payload: GitHub Push Event
-
/api/repo/create- Description: Triggered when a repository, branch, or tag is created.
- Environment Variable:
repo_create - Payload: GitHub Create Event
-
/api/repo/delete- Description: Triggered when a repository, branch, or tag is deleted.
- Environment Variable:
repo_delete - Payload: GitHub Delete Event
-
/api/repo/branch/create- Description: Triggered when a branch is created.
- Environment Variable:
repo_branch_create - Payload: Similar to GitHub Create Event, but specifically for branches.
-
/api/repo/branch/delete- Description: Triggered when a branch is deleted.
- Environment Variable:
repo_branch_delete - Payload: Similar to GitHub Delete Event, but specifically for branches.
-
/api/repo/tag/create- Description: Triggered when a tag is created.
- Environment Variable:
repo_tag_create - Payload: Similar to GitHub Create Event, but specifically for tags.
-
/api/repo/tag/delete- Description: Triggered when a tag is deleted.
- Environment Variable:
repo_tag_delete - Payload: Similar to GitHub Delete Event, but specifically for tags.
-
/api/repo/fork- Description: Triggered when a repository is forked.
- Environment Variable:
repo_fork - Payload: GitHub Fork Event
-
/api/repo/release/publish- Description: Triggered when a release is published.
- Environment Variable:
repo_release_publish - Payload: GitHub Release Event
-
/api/repo/release/update- Description: Triggered when a release is updated.
- Environment Variable:
repo_release_update - Payload: GitHub Release Event
-
/api/repo/release/delete- Description: Triggered when a release is deleted.
- Environment Variable:
repo_release_delete - Payload: GitHub Release Event
Issue Events
These endpoints handle various issue-related events. The X-GitHub-Event header should be issues, and the action field in the JSON payload determines the specific event.
POST /api/issues/{event_type}
Endpoints:
-
/api/issues/open- Description: Triggered when an issue is opened.
- Expected
action:opened - Environment Variable:
issues_open - Payload: GitHub Issues Event
-
/api/issues/close- Description: Triggered when an issue is closed.
- Expected
action:closed - Environment Variable:
issues_close - Payload: GitHub Issues Event
-
/api/issues/reopen- Description: Triggered when an issue is reopened.
- Expected
action:reopened - Environment Variable:
issues_reopen - Payload: GitHub Issues Event
-
/api/issues/update- Description: Triggered when an issue is edited.
- Expected
action:edited - Environment Variable:
issues_update - Payload: GitHub Issues Event
-
/api/issues/label/clear- Description: Triggered when all labels are removed from an issue.
- Expected
action:unlabeled(when all labels are removed) - Environment Variable:
issues_label_clear - Payload: GitHub Issues Event
-
/api/issues/label/update- Description: Triggered when a label is added or removed from an issue.
- Expected
action:labeledorunlabeled(when a single label is added/removed) - Environment Variable:
issues_label_update - Payload: GitHub Issues Event
-
/api/issues/comment/create- Description: Triggered when a comment is created on an issue.
- Expected
action:created(within thecommentobject of the payload) - Environment Variable:
issues_comment_create - Payload: GitHub Issue Comment Event
-
/api/issues/comment/update- Description: Triggered when a comment on an issue is edited.
- Expected
action:edited(within thecommentobject of the payload) - Environment Variable:
issues_comment_update - Payload: GitHub Issue Comment Event
-
/api/issues/comment/delete- Description: Triggered when a comment on an issue is deleted.
- Expected
action:deleted(within thecommentobject of the payload) - Environment Variable:
issues_comment_delete - Payload: GitHub Issue Comment Event
-
/api/issues/assign- Description: Triggered when an issue is assigned.
- Expected
action:assigned - Environment Variable:
issues_assign - Payload: GitHub Issues Event
-
/api/issues/unassign- Description: Triggered when an issue is unassigned.
- Expected
action:unassigned - **Env
