Closed bobvanoorschot closed 1 year ago
Yes exactly, in testing Coolify this is the most obvious omission. I have decoupled Nuxt generated (static) frontends that are fed with content from Strapi backends. In Strapi the editors can trigger a build by hitting a button which calls a webhook url and triggers the build (currently building on Github actions).
I imagine this is a reasonable common scenario and it would be great to have a solution within Coolify.
I have the exact same use case and this is the only thing preventing me from using coolify in production for clients. I have yet to find a workaround until internal webhooks are available 😅
+1 on that. @narduin Have you found a workaround? I'm curious because I currently have no idea how to auto-update my ElderJS-Website when content on Directus CMS changes...
For everyone interested: I have managed to update a nodejs app via webhook from Directus. The steps:
1. Add an empty testfile.txt to the root of your repository
2. Add a GitHub action:
name: commitfiles
on:
# Runs on pushes targeting the default branch
#push:
# branches: ["master"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Allows external webhook trigger
repository_dispatch:
types: [webhook]
jobs:
job1:
runs-on: [ubuntu-latest]
steps:
- name: checkout
uses: actions/checkout@v2
- name: Modify value # Tried to modify the files based on existing testfile.txt
run: |
echo $RANDOM >> testfile.txt
- name: move to dir # Move the generated files into output folder
run: |
mkdir -p output
yes| cp -rf testfile.txt ./output/
- name: Commit files # commit the output folder
run: |
git config --local user.email "{YOUR_MAIL}"
git config --local user.name "{YOUR_GITHUB_USERNAME}"
git add ./output
git commit -m "Add changes"
- name: Push changes # push the output folder to your repo
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
force: true
This action adds a random number to testfile.txt and places the result in a (new) folder /output in the repository. If the folder and file already exist, they are updated with a new random number. The changes are then committed to the repository, which in turn triggers the coolify webhook.
3. Trigger the GitHub Action via Webhook in the CMS:
In Directus you are able to build a flow that calls a webhook each time the content is updated/added/deleted. Don't use the "webhook" function for this, but really flows, because you need to specify the hook body.
Request: POST URL: https://api.github.com/repos/{GitHub username}/{Repo}/dispatches Headers:
Accept: application/vnd.github+json
Authorization: Bearer {GitHub Token}
Body: {"event_type":"webhook"}
Create your token with repo scope like this: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token The "event_type" is generic, but it needs to be the same as defined in the GitHub Action.
For me this configuration worked. Hope it helps you guys, too!
@oberbayer thanks a lot for sharing this, I had not found any slolution and will test yours soon :)
@oberbayer I hade Create a GitHub actions, for you can execute a deploy from a GitHub actions, You can help me in my GitHub action or test? https://github.com/marketplace/actions/coolify-application-deploy https://github.com/themarkwill/coolify-actions
In this case you not need change your story of commit for execute a deploy!
In this case you can deploy:
name: commitfiles
on:
# Runs on pushes targeting the default branch
#push:
# branches: ["master"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Allows external webhook trigger
repository_dispatch:
types: [webhook]
jobs:
job1:
runs-on: [ubuntu-latest]
steps:
- name: checkout
uses: actions/checkout@v2
- name: Deploy to coolify
uses: themarkwill/coolify-actions@v0.0.4 #deploy
with:
coolify-url: ${{ secrets.COOLIFY_URL }} # Required
coolify-app-id: ${{ secrets.COOLIFY_APP_ID }} #Required
coolify-token: ${{ secrets.COOLIFY_TOKEN }} #Required
I need some hooks for my projects too especially after deployment success and in the middle of deployment, because every new project i deploy i need to upload some private files and new env.
Without hook I have no idea how to use this to deploy php application.
Just to update people watching this issue, the developer said the following today on Discord:
webhooks will come very soon. I’m migrating the codebase to tRPC, so the frontend API calls will be separated from the API (way better DX). It would take a week to finish. After that, I will focus on making a reliable REST API for remote calling (that includes custom webhooks), so everyone can integrate Coolify into their current workflows. I have a LOT of things coming from January - let’s say I would like to go all-in on Coolify.
This will be supported in v4.
It would be nice if you can create custom build webhooks. That you could rebuild an application from a CMS.