https://github.com/actionsflow/webhook2github
Forward webhook to github repository_dispatch event
https://github.com/actionsflow/webhook2github
github webhook workflows
Last synced: 4 months ago
JSON representation
Forward webhook to github repository_dispatch event
- Host: GitHub
- URL: https://github.com/actionsflow/webhook2github
- Owner: actionsflow
- License: apache-2.0
- Created: 2020-09-29T22:08:57.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2022-01-24T11:32:35.000Z (about 4 years ago)
- Last Synced: 2025-03-24T09:04:17.459Z (10 months ago)
- Topics: github, webhook, workflows
- Language: TypeScript
- Homepage:
- Size: 224 KB
- Stars: 12
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE_APACHE
Awesome Lists containing this project
README
# webhook2github
This API enables forward webhook requests to [github repository_dispatch event webhook](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#repository_dispatch).
API Endpoint: [`https://webhook.actionsflow.workers.dev/`](https://webhook.actionsflow.workers.dev/)
```bash
https://webhook.actionsflow.workers.dev///?__token=
```
The default response of the webhook will use [the github `create-a-repository-dispatch-event` API response](https://docs.github.com/en/rest/reference/repos#create-a-repository-dispatch-event). You can use search params `__response_code`, `__response_content_type`, `__response_body` to specify a custom response.
You can also use headers `X-Github-Authorization` instead of search params `__token` for more security.
The webhook also supports the cross-origin resource sharing request.
For example:
```bash
curl --request POST 'https://webhook.actionsflow.workers.dev/actionsflow/webhook2github/webhook/webhook?__token=' \
--header 'Content-Type: application/json' \
--data-raw '{
"key": "value"
}'
```
Specify response code example:
```bash
curl --request POST 'https://webhook.actionsflow.workers.dev/actionsflow/webhook2github/webhook/webhook?__token=&__response_code=200' \
--header 'Content-Type: application/json' \
--data-raw '{
"key": "value"
}'
```
An axios example:
```javascript
var axios = require('axios')
var data = JSON.stringify({ key: 'value' })
var config = {
method: 'post',
url:
'https://webhook.actionsflow.workers.dev/actionsflow/webhook2github/webhook/webhook?__token=',
data: data,
}
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data))
})
.catch(function (error) {
console.log(error)
})
```
## How It Works
This API will forward the following original webhook request:
```bash
https://webhook.actionsflow.workers.dev///?__token=
```
To `https://api.github.com/repos///dispatches`, with body:
```json
{
"event_type": "webhook",
"client_payload": {
"path": "",
"method": "",
"headers": "",
"body": ""
}
}
```
So Github actions will be triggered with `repository_dispatch` event.