Skip to content

[Feat] Scripts on events (#1070)#1196

Draft
pietervanleuven wants to merge 8 commits into
vitodeploy:4.xfrom
pietervanleuven:feat/script-event-hooks
Draft

[Feat] Scripts on events (#1070)#1196
pietervanleuven wants to merge 8 commits into
vitodeploy:4.xfrom
pietervanleuven:feat/script-event-hooks

Conversation

@pietervanleuven

Copy link
Copy Markdown

Closes #1070

Attach an existing Script to a lifecycle event so it runs automatically whenever that event fires in a given project.

Events

Event Injected variables
Site created site_domain, site_path, site_type, server_name, server_ip
Site deleted site_domain, server_name, server_ip
Server installed server_name, server_ip
Server deleted server_name, server_ip
Service installed service_name, service_type, service_version, server_name, server_ip
Service uninstalled service_name, service_type, server_name, server_ip

Design notes

  • Hooks are project-scoped — only fire for events in the configured project.
  • Delete events carry scalar primitives (name, IP, project ID) because the model row is gone by the time listeners run.
  • Hook failures are caught and logged per-hook; they never surface to the originating action.
  • Script variables not present in the event map are filled with '' (no prompt, no abort).

Changes

  • ScriptEventHook model + migration + factory
  • CreateScriptEventHook / UpdateScriptEventHook actions (project write-access enforced)
  • ScriptHookController + ScriptEventHookPolicy + ScriptEventHookResource
  • RunScriptEventHooks listener wired to all 6 events in AppServiceProvider
  • ExecuteScript::executeForHook() — transaction-wrapped, bypasses user auth
  • New events: ServerInstalledEvent, ServerDeletedEvent, ServiceInstalledEvent, ServiceUninstalledEvent
  • UI: hooks management sheet + table on the script show page

Testing

16 new feature tests covering CRUD, all 6 event types, disabled/cross-project skip, variable injection, and exception isolation.

@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5ad89a87-add5-4a9d-8ee7-f8308288ca95

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Pieter Van Leuven and others added 8 commits July 6, 2026 23:19
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Delete events carry scalar primitives so the listener can reference
them after the model row is gone.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- ExecuteScript::executeForHook() runs a script in hook context,
  injecting event variables and skipping user-auth validation
- RunScriptEventHooks handles all 6 event types; failures are caught
  per-hook so they never surface to the originating action
- AppServiceProvider registers the listener for all 6 events
- GetBootstrap exposes event metadata to the frontend via configs()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
16 tests covering CRUD, all 6 event types, disabled/cross-project
skip, variable injection, and exception isolation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@pietervanleuven pietervanleuven force-pushed the feat/script-event-hooks branch from 6dce205 to f602e70 Compare July 6, 2026 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scripts on events

1 participant