Convert DockerHub webhook to Slack notification
A short example on integrating two services directly by utilizing Functions.
Last updated
Was this helpful?
A short example on integrating two services directly by utilizing Functions.
Last updated
Was this helpful?
Many Docker registries provide a way to notify team in chat channels when new images are pushed (if you are waiting for a build complete). Letâs add this capability to the official DockerHub registry! :)
Prerequisites:
Docker
Create a bucket here https://my.webhookrelay.com/buckets
Once you have it, in the inputs section you will find your public input endpoint, copy it:
Add a new DockerHub webhook setting pointing at our public input endpoint (DockerHub docs):
Push a new Docker image:
We should be able to see a new incoming webhook. It looks like this:
Go to the Functions page and click on a âCreate Functionâ button. Enter a name, for example âdockerhub-to-slackâ and click âSubmitâ.
You can now copy/paste webhook payload into the ârequest bodyâ area for later tests. In the code editor letâs add a function to get repository name and prepare a Slack webhook payload (currently functions have to be written in Lua but more examples for WebAssembly will be added soon):
Click âSaveâ and then try testing it with the âSendâ button:
Navigate to https://api.slack.com/messaging/webhooks and click âCreate your Slack appâ. Select your workspace, enter a name that you will remember.
Create a new incoming webhook configuration, copy âWebhook URLâ (it starts with https://hooks.slack.com/services/T3...
), we will need to supply it to Webhook Relay.
Open your bucket details (via https://my.webhookrelay.com/buckets)
Open âOUTPUT DESTINATIONSâ tab and create a new output called âSlackâ with the Slack URL from step 2:
Once created, click on the âcodeâ symbol and from the dropdown select dockerhub_to_slack
function:
Push new image to DockerHub, you should see a new notification in your Slack channel:
Thatâs it, feel free to continue modifying Lua function to include pusherâs name and message format. Following this process you can transform any webhook into any other webhook.
Have fun!