Page Contents
Generate an API for Cloud GitHub
Create a new API labeled “GitHub” for integration purposes. Make sure to enable the “Send Notification” option in the available settings. Upon completion, you’ll notice the JSON Template tab visible, where you can input the JSON template format.
Request
http://[publicserverip]:14125/api/notify?apikey=C1TA7MH12E43A72OH03L3J336ANGWXE5B6DJ&room=MarketingRoom
Note: To maintain cleaner and more readable web addresses, it’s advisable to exclude spaces in URLs to prevent the insertion of “%20” encoding. This ensures that URLs remain concise and accurately respond to requests.
JSON Template
Action: {{headers.x-github-event}} Repository name: {{repository.name}} Message: {{head_commit.message}} By: {{head_commit.committer.name}}
Description
Fields | Details |
---|---|
API Key | Includes the API key, to trigger notifications via the designated server IP |
room | Room name, you want to send the notification. |
color | Background Color |
otr | Off-The-Record messages. 1 – ON. 0 – OFF. optional. Default value is 0. |
notify | 1 – Trigger User Notification. 0 – No Notification. optional. Default value is 1. |
JSON Navigation with Dot Notation
Using dot notation to access child values within JSON headers streamlines navigation through nested structures by denoting the hierarchical connection between keys and their respective nested values.
To access the name value, you simply use “.” notation, like “head_commit.committer.name,” which will return “JohnDoe“.
GitHub Push Events with Webhook Headers
Interpreting webhook headers labeled “x-GitHub-Event: Push” involves reacting to GitHub’s push events, enabling automated responses such as deployment or notifications triggered by changes in repositories.Within “{{headers.x-github-event}}“, “headers” points to the container holding header details, and “x-github-event” indicates the specific header name from which the value is extracted.
Configuring Webhooks in GitHub Repository Settings
In GitHub repository settings, selecting “Settings > Webhooks” allows users to configure automated notifications and trigger actions in external systems based on repository events. Users can specify the events that trigger webhook payloads and the target URL where data is sent.
Payload URL in GitHub Webhooks
The Payload URL within “Settings > Webhooks” designates the destination where data is dispatched upon webhook events, enabling smooth interoperability among platforms by delivering immediate updates to specified URLs.
Validating the Payload URL in GitHub Webhooks
To ensure the effectiveness of the Payload URL in a webhook, a trial request is dispatched, and upon successful transmission, a green checkmark indicates the confirmation of the link’s operational status, signaling its readiness for automated data transfer.
GitHub Notification
The GitHub notification, presented in a chat window, showcases key details in a structured format:
Event: Indicates the action performed, such as a “Push” event.
Repo: Identifies the repository involved, here labeled “UpdateClientAnalyze“.
Message: Provides additional context, like the update version, in this case, “Configuration Version 10,” along with the user responsible, noted as “JohnDoe“.