Webhook
You can use webhook trigger to receive data from any service.
Usage
on:webhook:method: post
Setup Webhook URL
The webhook URL is in the following format, you should set this URL to the 3rd party service webhook settings.
https://webhook.actionsflow.workers.dev/<owner>/<repo>/<workflow-file-name>/webhook?__token=<your-github-personal-token>
<workflow-file-name>
is your workflow file name without ext. For example, if you define a webhook trigger at./workflows/webhook.yml
, then,<workflow-file-name>
iswebhook
You need to generate personal access tokens with
repo
scope at Github settings, then replace<your-github-personal-token>
Here is an example for sending a webhook event:
curl --request POST 'https://webhook.actionsflow.workers.dev/actionsflow/actionsflow/webhook/webhook?__token=<your-github-personal-token>' \--header 'Content-Type: application/json' \--data-raw '{"key": "value"}'
Learn more about webhook URL, see here
IFTTT Webhook Request example
You can send webhook event from IFTTT webhook.
For example, you can input the following value at IFTTT webhook settings:
- URL:
https://webhook.actionsflow.workers.dev/actionsflow/actionsflow/webhook/webhook?__token=<your-github-personal-token>
- Method:
POST
- Content Type:
application/json
- Body
{"key": "value"}
Tips: if your field content need to be escaped, you should surround it with
<<<>>>
Options
method
, optional,string
orstring[]
, you can define one or more as the specific method that the webhook should listen, the default isundefined
, means that the webhook would listen all methods. The options value can beget
,post
,put
,patch
,delete
,head
,options
path
, optional,string
, you can define a path as the specific path that the webhook should listen, the default isundefined
, means that the webhook would listen all path with prefixhttps://webhook.actionsflow.workers.dev/actionsflow/actionsflow/webhook/webhook
. The options value can be/
,/user/:userId
deduplicationKey
, optional. The poll trigger deduplicates the array we see each poll against the id key. If the id key does not exist, you should specify an alternative unique key to deduplicate, you can use path format, like:id
,data.id
,item.data.key
, If neither are supplied, we fallback to looking forkey
, if neither are supplied, we will hash the item, and generate a unique key
You can use General Config for Actionsflow Trigger for more customization.
Note, the default value of
config.shouldDeduplicate
isfalse
for this trigger.
Outputs
An outputs example:
{"headers": {"content-type": "application/json"},"method": "post","query": {"test": "1"},"querystring": "test=1","search": "?test=1","body": {"id": "testid","title": "title"},"params": {}}
You can use the outputs like this:
on:webhook:jobs:print:name: Printruns-on: ubuntu-lateststeps:- name: Print Outputsenv:method: ${{ on.webhook.outputs.method }}body: ${{ toJson(on.webhook.outputs.body) }}headers: ${{ toJson(on.webhook.outputs.headers) }}run: |echo method: $methodecho headers $headersecho body: $body
How It Works
We implement Webhook feature by using Github's repository_dispatch
, So we made the webhook2github project
This API will forward the following original webhook request:
https://webhook.actionsflow.workers.dev/<owner>/<repo>/<your-path>?__token=<your-github-personal-token>
To https://api.github.com/repos/<owner>/<repo>/dispatches
, with body:
{"event_type": "webhook","client_payload": {"path": "<your-path>","method": "<request.method>","headers": "<request.headers>","body": "<request body>"}}
So Github actions will be triggered with repository_dispatch
event.