coolify icon indicating copy to clipboard operation
coolify copied to clipboard

[Bug]: Watch paths do not work

Open ari-party opened this issue 1 year ago • 2 comments

Description

I set watch paths to /packages/mtc-artillery/**, I create a file in that folder. A new deployment is not queued when I push it.

I tried !/packages/mtc-artillery/** !/packages/mtc-artillery and /packages/mtc-artillery

Minimal Reproduction (if possible, example repository)

image Repository: mtc-artillery

Exception or Error

No response

Version

v4.0.0-beta.306

ari-party avatar Jul 05 '24 23:07 ari-party

Try removing the / infront of the watch paths: packages/mtc-artillery/**

aelmiger avatar Jul 06 '24 13:07 aelmiger

Try removing the / infront of the watch paths: packages/mtc-artillery/**

ahh thank you that fixes it.

but this issue should in my opinion remain open as that slash should work as project root...

ari-party avatar Jul 06 '24 15:07 ari-party

Try removing the / infront of the watch paths: packages/mtc-artillery/**

ahh thank you that fixes it.

but this issue should in my opinion remain open as that slash should work as project root...

I believe the way the watch paths work it does a string pattern match on the committed files list received from the webhook (source control) https://github.com/coollabsio/coolify/blob/e9158b7305bb9253fe75a0e76ef34af62f75199b/app/Models/Application.php#L1077-L1090

Also, the watch paths are gitignore styled matched from the root of the repository

mohdmusthafa avatar Jul 09 '24 16:07 mohdmusthafa

A note: You need to escape special characters if you use them within the folder name, i.e. [blog] needs to be escaped \[blog\]

hk86 avatar Jul 29 '24 13:07 hk86

I have a monorepo like this:

someFile.tmp
/apps
  /appA
  /appB
/packages
  /common
  /stuff

In the appA I would like an auto deploy if anything changes ignoring what is in /apps/appB/*. And this is not working.


To watch a folder, this is my experience:

/apps/appA     # not working
/apps/appA/**  # not working
apps/appA/**   # working

The problem with watching, is that I want to watch also the root files and /common with appA. That's why ignore would be great.


I tried prefixing with !, but it's not supported.

Maybe this would support it

public function isWatchPathsTriggered(Collection $modified_files): bool
{
    if (is_null($this->watch_paths)) {
        return false;
    }

    $watch_paths = collect(explode("\n", $this->watch_paths));

    // Separate includes and excludes
    $excludes = $watch_paths->filter(fn ($glob) => str_starts_with($glob, '!'))
                            ->map(fn ($glob) => substr($glob, 1)); // Remove '!'
    
    $includes = $watch_paths->reject(fn ($glob) => str_starts_with($glob, '!'));

    $matches = $modified_files->filter(function ($file) use ($includes, $excludes) {
        // If the file matches any exclusion pattern, ignore it
        if ($excludes->contains(fn ($glob) => fnmatch($glob, $file))) {
            return false;
        }

        // Check if the file matches any inclusion pattern
        return $includes->contains(fn ($glob) => fnmatch($glob, $file));
    });

    return $matches->count() > 0;
}

Like this, I would be able to do in my appA:

!apps/appB/**
!packages/stuff/**

Would love to have this 🙏

jycouet avatar Mar 08 '25 20:03 jycouet

This will be fixed in the next version.

Negotiate prefixes are working + we parse the paths so it will match the incoming changed_files from Git webhooks (If you set /path/something, but webhook sends path/something, they will match)

andrasbacsai avatar Sep 25 '25 12:09 andrasbacsai

I would like to check on my https://app.coolify.io/ but we are still in v4.0.0-beta.428. You know when is the plan to move up? Thx

jycouet avatar Oct 13 '25 15:10 jycouet