Feature: run local scripts from hooks #7
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Use case
Alakazam hooks currently run
abra.shfunctions. This works well for operations that are generic enough to belong in a recipe. However, I also have custom automations that I want to trigger at the same hooks. These are specific to our situation and don't belong in a recipe'sabra.sh.I'd like to extend the hook system to allow running a local shell script instead of an abra command, so deployment-specific automation can be run from the same hooks.
Proposal
Add a
scriptprefix to hook entries. When alakazam encountersscriptas the first token, it runs a local shell script instead of calling abra.Syntax:
Path resolution: relative paths are resolved against the root path defined in alakazam.yml; absolute paths are used as-is.
Context via environment variables: before running the script, alakazam sets:
ALAKAZAM_APP_DOMAINe.g.nextcloud.example.comALAKAZAM_APP_SERVERe.g.server.example.comALAKAZAM_INSTANCE_DOMAINe.g. example.comPositional arguments written in the hook entry are passed directly to the script.
Fallback: if the specified script path does not resolve to an existing file, alakazam falls back to treating
scriptas a container name and calls abra normally. This avoids a breaking change if any stack happens to have a container namedscript.I think it's a good idea, especially if the hooks are customized on a very specific use case. We would mostly try to upstream our customization into
abra.shto make them available for the public. Therefore we would rarely use thescripthook and can't guarantee that this won't break by any further changes, as long we haven't a test suite for alakazam.