From 28278914594de24bf5b9a477b465cb13f999de41 Mon Sep 17 00:00:00 2001 From: pulltheflower Date: Tue, 16 Mar 2021 17:50:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84events=E7=9A=84=E6=96=87?= =?UTF-8?q?=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/course/actions.md | 130 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 129 insertions(+), 1 deletion(-) diff --git a/src/course/actions.md b/src/course/actions.md index 4296542..f401c85 100644 --- a/src/course/actions.md +++ b/src/course/actions.md @@ -14,4 +14,132 @@ - wiki - commit - deployment -- alert \ No newline at end of file +- alert + + +## push + +使用push类型来监听用户仓库的推送代码事件 + +### 示例 + +在使用`transitions`中监听用户的push事件并执行相应的`action`,当用户向`feature1`推送代码的时候,触发相应的action + +```yaml +step1: + link: '{{first_issue_url}}' + description: "第一步" + transitions: + events: ['push'] + with: 'feature1' + action: + - type: issue_comment.created + with: comment.md + to: step9 +``` + +### Options + +当`events`为push的时候,支持的参数 + +| 参数 | 类型 | 描述 | 默认 | 是否为必要参数 | +| --- | --- | --- | --- | --- | +| with | String | 监听用户推送到的分支 | | 是 | + + +## note + +使用push类型来监听用户仓库的推送代码事件 + +### 示例 + +在使用`transitions`中监听用户的note(评论)事件并执行相应的`action`,当用户回复相应内容的时候,触发相应的`action` + +```yaml +step1: + link: '{{first_issue_url}}' + description: "不同操作系统的安装介绍" + transitions: + - events: ['note_events'] + with: A + action: + - type: issue_comment.created + with: 004_3_window_git_install.md + - type: choice + with: next.md + to: step2 + - events: ['note_events'] + with: B + action: + - type: issue_comment.created + with: 004_4_macOS_git_install.md + - type: choice + with: next.md + to: step2 + - events: ['note_events'] + with: C + action: + - type: issue_comment.created + with: 004_5_linux_git_install.md + - type: choice + with: next.md + to: step2 +``` + +也可以使用正则匹配来匹配用户输入评论的内容,如果用户评论的内容和正则表达式相匹配,则出发相应的`action` + +```yaml +step1: + link: '{{first_issue_url}}' + description: "使用正则匹配标题" + transitions: + - events: ['note_events'] + left: '/^#{1,6}\s.+/' + operator: regexp + right: '{{object_attributes.note}}' + action: + - type: issue_comment.created + with: nice_job.md + to: step2 +``` + +### Options + +当`events`为note的时候,支持的参数 + +| 参数 | 类型 | 描述 | 默认 | 是否为必要参数 | +| --- | --- | --- | --- | --- | +| with | String | 用户回复的内容 | | 否 | +| left | String | 正则表达式 | | 否 | +| operator | String | 操作符,这里使用正则匹配,应该为regexp | | 否 | +| right | String | 监听到符合条件的对象的属性,object_attributes为对象的所有属性,这里用到的属性为note | | 否 | + + +## issue + +使用push类型来监听用户仓库的推送代码事件 + +### 示例 + +在使用`transitions`中监听用户的issue事件并执行相应的`action`,下面的示例是指当用户关闭一个issue的时候,触发相应的action + +```yaml +step6: + link: '{{chapter_3_issue}}' + description: "完成当前章节学习" + transitions: + events: ['close_issue'] + action: + - type: create_issue + title: "Markdown :链接" + with: 004_1_link_basic.md + store: + chapter_4_issue: '{{result.data.html_url}}' + - type: issue_comment.created + with: 003_5_end_2.md + to: end +``` + +### Options + +`close_issue` 事件无需额外的参数,系统默认会匹配step中的`link`参数指向的issue \ No newline at end of file -- GitLab