定制 lakedrops/gitlab-playbooks 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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 typeMachine namePurpose
PlaybookplaybookA named, ordered collection of steps.
Playbook Stepplaybook_stepOne step's GitLab configuration.

playbook_step fields:

  • field_playbook — reference to the parent playbook.
  • 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 use field_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 typeMachine namePurpose
Playbook Runplaybook_runOne execution of a playbook.
Run Steprun_stepThe runtime state of one step within a run.

run_step fields:

  • field_run — reference to the playbook_run.
  • field_step — reference to the playbook_step definition.
  • field_statuspending / 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

ModelTriggerResponsibility
gitlab_playbooks_run_pageECA Endpoint response /eca/playbook/runRenders the run page shell and the eca_htmx_poll region that polls the status fragment.
gitlab_playbooks_statusECA Endpoint response /eca/playbook/statusRenders the steps list: status, GitLab deep link, an enabled Start button on the first pending step, and "Locked" on later pending steps.
gitlab_playbooks_startECA Endpoint response /eca/playbook/startTriggers the step's GitLab pipeline, stores the pipeline ID and web URL, and sets the step to running.
gitlab_playbooks_pollECA cron eventLoads running run steps, reads each pipeline status from GitLab, updates the step, and advances.
gitlab_playbooks_accessECA entity accessGrants 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

PathModelNotes
/eca/playbook/run?run=IDgitlab_playbooks_run_pageThe run page with the polling region.
/eca/playbook/status?run=IDgitlab_playbooks_statusThe fragment HTMX swaps in.
/eca/playbook/start?step=IDgitlab_playbooks_startStarts 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

  1. Create a Playbook node, e.g. "Deploy Service".
  2. Create one Playbook Step node per step, each referencing the playbook via field_playbook, with a field_weight for ordering and the GitLab field_gitlab_instance, field_project_id, and field_trigger_id.
  3. 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).
  4. 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 uses eca_htmx, and the endpoints use eca_endpoint.
  • US English throughout.

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0-or-later
  • 更新时间: 2026-06-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固