Welcome gentl-octocats, today I wanted to create a Github Action to use IFTTT Webhooks and i know that all i need will be a simple curl in any Linux container, but, I'm a developer, and i like to try new thinks. And at the moment of the writing what is the hottest news in the Javascript environment?
So let's start building a github action with a Deno runner.
The image of the Denosaur
First of all we need an image with Deno, and after a simple research i have found hayd/alpine-deno:1.1.0.
So let's start writing the Dockerfile
FROM hayd/alpine-deno:1.1.0WORKDIR /app# Prefer not to run as root.USER deno# These steps will be re-run upon each file change in your working directory:ADD . .# Compile the main app so that it doesn't need to be compiled each startup/entry.RUN deno cache main.ts
CMD ["run", "--allow-net", "--allow-env", "/app/main.ts"]
Using the Denosaur
The actions it's a simple ts file how will fetch a request to the webhook like this
constinput=(key:string)=>Deno.env.get(`INPUT_${key}`);consteventName=input('EVENT');constkey=input('KEY');constvalue1=input('VALUE1');constvalue2=input('VALUE2');constvalue3=input('VALUE3');console.log(`calling webhook for ${eventName} with`,value1,value2,value3);awaitfetch(`https://maker.ifttt.com/trigger/${eventName}/with/key/${key}`,{method:'POST',headers:{'Content-Type':'application/json',},body:JSON.stringify({value1,value2,value3}),});
The Octocat Action
End last but not least the github action definition
# action.ymlname:'IFTTTWebhook'description:'CallanIFTTTWebhook'inputs:event:# id of inputdescription:'IFTTTwebhookevent'required:truekey:description:'IFTTTwebhookkey'required:truevalue1:description:'IFTTTwebhookoptionalparameter'required:falsevalue2:description:'IFTTTwebhookoptionalparameter'required:falsevalue3:description:'IFTTTwebhookoptionalparameter'required:falseruns:using:'docker'image:'Dockerfile'
End of the story
And at the end of the story, in only 5 minutes I have made ifttt-webhook-action using Deno.
A GitHub action that triggers an IFTTT webhooks
event. This is useful for example when you want to trigger a IFTTT webhook after
your deployment succeeds.