lakedrops/gitlab-playbooks
Composer 安装命令:
composer require lakedrops/gitlab-playbooks
包简介
A generic, config-only framework for running ordered GitLab pipeline playbooks from Drupal, with a live run page powered by HTMX polling.
README 文档
README
A generic, config-only Drupal recipe that provides a "playbooks" framework for running ordered GitLab pipelines — a Drupal-native replacement for Mattermost Playbooks. There is no custom PHP: the entire runtime is expressed as content, ECA models, and Views.
Adding a new playbook is pure content entry. No module, no code.
What you get
- Four node types (definitions and runtime data).
- Five ECA models that render the run page, serve the live status fragment, start a step's GitLab pipeline, poll running pipelines on cron, and gate access.
- Two Views used by the page and the cron poller.
- A run page with an HTMX polling region (via
eca_htmx) that refreshes the step statuses every few seconds without a full page reload. The polled fragment is served by an ECA Endpoint response — no custom controller.
Data model
Definitions (content)
Definitions are content, not config entities. This is a deliberate decision to honor the zero-PHP constraint:
- A custom config entity type would require a PHP module to declare it.
- A custom simple-config object would require a PHP module to ship its schema.
Modeling definitions as node types keeps everything pure config to install, and makes "adding a playbook" a content-authoring task that any editor can do through the standard node UI.
| Node type | Machine name | Purpose |
|---|---|---|
| Playbook | playbook | A named, ordered collection of steps. |
| Playbook Step | playbook_step | One step's GitLab configuration. |
playbook_step fields:
field_playbook— reference to the parentplaybook.field_weight— the step order.field_gitlab_instance— the GitLab server config entity ID.field_project_id— the GitLab project ID.field_trigger_id— the pipeline trigger ID (or usefield_pipeline_ref).field_pipeline_ref— optional pipeline ref.field_variables— optional pipeline variables.field_auto_advance— whether the next step starts automatically on success.
Runtime (content)
| Node type | Machine name | Purpose |
|---|---|---|
| Playbook Run | playbook_run | One execution of a playbook. |
| Run Step | run_step | The runtime state of one step within a run. |
run_step fields:
field_run— reference to theplaybook_run.field_step— reference to theplaybook_stepdefinition.field_status—pending/running/success/failed.field_pipeline_id— the GitLab pipeline ID created by the trigger.field_web_url— the GitLab pipeline deep link.field_started/field_finished— timestamps.
ECA models
| Model | Trigger | Responsibility |
|---|---|---|
gitlab_playbooks_run_page | ECA Endpoint response /eca/playbook/run | Renders the run page shell and the eca_htmx_poll region that polls the status fragment. |
gitlab_playbooks_status | ECA Endpoint response /eca/playbook/status | Renders the steps list: status, GitLab deep link, an enabled Start button on the first pending step, and "Locked" on later pending steps. |
gitlab_playbooks_start | ECA Endpoint response /eca/playbook/start | Triggers the step's GitLab pipeline, stores the pipeline ID and web URL, and sets the step to running. |
gitlab_playbooks_poll | ECA cron event | Loads running run steps, reads each pipeline status from GitLab, updates the step, and advances. |
gitlab_playbooks_access | ECA entity access | Grants access to playbook_run and run_step content when the user has the configured permission. |
The polled fragment is served by ECA Endpoint, not by eca_htmx
eca_htmx only provides the polling region (eca_htmx_poll). The fragment
that HTMX swaps in is returned by an ordinary ECA Endpoint response event
(gitlab_playbooks_status). The EndpointResponseEvent already implements
RenderEventInterface, so it can return the render array that the render
actions build — there is no need for a dedicated HTMX response event, and none
is added here.
Endpoints
| Path | Model | Notes |
|---|---|---|
/eca/playbook/run?run=ID | gitlab_playbooks_run_page | The run page with the polling region. |
/eca/playbook/status?run=ID | gitlab_playbooks_status | The fragment HTMX swaps in. |
/eca/playbook/start?step=ID | gitlab_playbooks_start | Starts one run step's pipeline. |
Install
drush recipe recipes/gitlab-playbooks
drush cache:rebuild
This installs the required modules (including gitlab_api and its
eca_gitlab_api submodule, which requires gitlab_api 3.0.x or newer), the node
types and fields, the Views, and the ECA models.
Configure a GitLab server
The GitLab API integration needs at least one configured GitLab server. Create
one at Administration » Configuration » Web services » GitLab API, and use
its machine name in each step's field_gitlab_instance.
How to define a playbook
- Create a Playbook node, e.g. "Deploy Service".
- Create one Playbook Step node per step, each referencing the playbook
via
field_playbook, with afield_weightfor ordering and the GitLabfield_gitlab_instance,field_project_id, andfield_trigger_id. - To run it, create a Playbook Run node referencing the playbook, then
create a Run Step node per step (referencing the run and the step
definition, with
field_status=pending). - Open
/eca/playbook/run?run=RUN_ID. The first pending step shows a Start button; later steps are locked until their predecessor succeeds. The status region refreshes automatically via HTMX.
A future enhancement could auto-create the Run Step nodes from the Playbook definition via an additional ECA model triggered on Playbook Run insert — still pure config.
Constraints honored
- Zero custom PHP. Everything is YAML config plus this README.
- Reuse, not reinvent. GitLab calls use
eca_gitlab_api, the polling region useseca_htmx, and the endpoints useeca_endpoint. - US English throughout.
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2026-06-22