diff --git a/src/course/actions.md b/src/course/actions.md index 6d7d2bbc37645dc5cf40957fdfc8a2e267c25514..721af963d554045bdd0ae84656110102abf6dad6 100644 --- a/src/course/actions.md +++ b/src/course/actions.md @@ -2,19 +2,16 @@ 目前 Learning Lab 支持的动作包括: -- '[close_issue](actions/close-issue.html)' -- '[open_issue](actions/open-issue.html)' -- 'create_issue' -- 'close_exam_result_issue' -- 'open_merge_request' -- 'close_merge_request' -- 'merge_request.create' -- 'merge_request.close' -- 'create_branch' -- 'delete_branch' -- 'gate' -- 'reply' -- 'issue_comment.created' -- 'note' -- 'choice' -- 'exam_result' \ No newline at end of file +- push +- tag_push +- note +- confidential_note +- issue +- confidential_issue +- merge_request +- pipeline +- Pages +- wiki +- commit +- deployment +- alert diff --git a/src/course/events.md b/src/course/events.md index 42965427b2f7e41d6467fbb449a132b903f707ac..f401c85f3dfe2e54368ef963f8e70fe5714cbccf 100644 --- a/src/course/events.md +++ b/src/course/events.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