Is it possible to overwrite the "run-mode" per action? #194
-
Hi there, I'm currently working on integrating captainhook into our project. We're using a docker-based setup and have a bunch of actions defined already. Some of the actions might be executed on the host machine, but others need to be executed inside docker (e.g. running migrations). Imagine having a setup like this:
{
"config": {
"bootstrap": "vendor/autoload.php",
"php-path": "php",
"run-mode": "docker",
"run-exec": "docker exec cli"
},
"pre-commit": {
"enabled": true,
"actions": [
{
"action": "\\CaptainHook\\App\\Hook\\PHP\\Action\\Linting",
"options": [],
"conditions": []
},
{
"action": "vendor/bin/phpcs {$STAGED_FILES|of-type:php}",
"options": [],
"conditions": [
{
"exec": "\\CaptainHook\\App\\Hook\\Condition\\FileStaged\\OfType",
"args": ["php"]
}
]
}
]
},
"post-merge": {
"enabled": true,
"actions": [
{
"action": "vendor/bin/console migrate",
"options": {},
"conditions": [
{
"exec": "\\CaptainHook\\App\\Hook\\Condition\\FileChanged\\Any",
"args": [
["src/Migration/*.php"]
]
}
]
}
]
}
} We could speed things up by running all actions (except the migrate command) on the host machine by introducing this {
"run-mode": "local",
"run-exec": ""
} But this doesn't work with the migrate command. Would be nice to have an option like this: @@ -30,7 +30,10 @@
"actions": [
{
"action": "vendor/bin/console migrate",
- "options": {},
+ "options": {
+ "run-mode": "docker",
+ "run-exec": "docker exec cli"
+ },
"conditions": [
{
"exec": "\\CaptainHook\\App\\Hook\\Condition\\FileChanged\\Any", Is it already possible somehow to achieve that? Would you be open for an PR that implements that? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
I would suggest to change the migrate command to something like docker exec "php vendor/bin/console migrate…" That‘s what the Cap’n would have to do anyway, start a ne "sub" process. If you want to keep both options, so people could still run everything in docker you would need two |
Beta Was this translation helpful? Give feedback.
I would suggest to change the migrate command to something like
docker exec "php vendor/bin/console migrate…"
That‘s what the Cap’n would have to do anyway, start a ne "sub" process.
If you want to keep both options, so people could still run everything in docker you would need two
Actions
one with thevendor/bin…
command and one with thedocker exec …
command and then apply conditions to each. One where you only run inrun-mode
docker and the other that checks forrun-mode
local.