Skip to content

Commit 57017eb

Browse files
committed
docs: add docs for actions
1 parent 85b5d51 commit 57017eb

File tree

2 files changed

+50
-14
lines changed

2 files changed

+50
-14
lines changed

README.md

+48-12
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,49 @@ label:
207207
| uniq()
208208
```
209209

210-
### `label` (list)
210+
### `actions[]` (list)
211+
212+
The `actions` key is a list of actions that can be taken on a Merge Request.
213+
214+
#### `actions[].name`
215+
216+
The name of the action, this is purely for debugging and your convenience. It's encouraged to be descriptive of the actions.
217+
218+
#### `actions[].if`
219+
220+
A key controlling if the action should executed or not.
221+
222+
The `if` field must be a valid [Expr-lang](https://expr-lang.org/) expression returning a boolean.
223+
224+
#### `actions[].then[]` (list)
225+
226+
The list of operations to take if the `action.if` returned `true`.
227+
228+
#### `actions[].then[].action`
229+
230+
This key controls what kind of action that should be taken.
231+
232+
- `close` to close the Merge Request.
233+
- `reopen` to reopen the Merge Request.
234+
- `lock_discussion` to prevent further discussions on the Merge Request.
235+
- `unlock_discussion` to allow discussions on the Merge Request.
236+
- `approve` to approve the Merge Request.
237+
- `unapprove` to approve the Merge Request.
238+
- `comment` to add a comment to the Merge Request (requires the `message` field)
239+
240+
#### `actions[].then[].message`
241+
242+
Required field for `action: comment`.
243+
244+
The message that will be commented on the Merge Request.
245+
246+
### `label[]` (list)
211247

212248
The `label` key is a list of the labels you want to manage.
213249

214250
These keys are shared between the `conditional` and `generate` label strategy. (more above these below!)
215251

216-
#### `label.name`
252+
#### `label[].name`
217253

218254
- When using `label.strategy: conditional`
219255

@@ -223,7 +259,7 @@ These keys are shared between the `conditional` and `generate` label strategy. (
223259

224260
**OMITTED** The `name` field must not be set when using the `generate` strategy.
225261

226-
#### `label.script` (required)
262+
#### `label[].script` (required)
227263

228264
> [!TIP]
229265
> See the [SCM engine expr-lang documentation](#expr-lang-information) for more information about [functions](#functions) and [attributes](#attributes) available.
@@ -232,7 +268,7 @@ The `script` field is an [expr-lang](https://expr-lang.org/) expression, a safe,
232268

233269
Depending on the `label.strategy` used, the behavior of the script changes, read more about this below.
234270

235-
#### `label.strategy` (optional)
271+
#### `label[].strategy` (optional)
236272

237273
SCM Engine supports two strategies for managing labels, each changes the behavior of the `script`.
238274

@@ -244,11 +280,11 @@ SCM Engine supports two strategies for managing labels, each changes the behavio
244280

245281
The `script` must return a `list of strings`, where each label returned will be added to the Merge Request.
246282

247-
##### `label.strategy: conditional` use-cases
283+
##### `label[].strategy: conditional` use-cases
248284

249285
Use the `conditional` strategy when you want to add/remove a label on a Merge Request depending on _something_. It's the default strategy, and the most simple one to use.
250286

251-
##### `label.strategy: conditional` examples
287+
##### `label[].strategy: conditional` examples
252288

253289
> [!NOTE]
254290
> The `script` field is a [expr-lang](https://expr-lang.org/) expression, a safe, fast, and intuitive expression evaluator.
@@ -283,11 +319,11 @@ label:
283319
script: merge_request.modified_files("*_test.go")
284320
```
285321

286-
##### `label.strategy: generate` use-cases
322+
##### `label[].strategy: generate` use-cases
287323

288324
Use the `generate` strategy if you want to manage dynamic labels, for example, depending on the file structure within your project.
289325

290-
##### `label.strategy: generate` examples
326+
##### `label[].strategy: generate` examples
291327

292328
> The `script` field is a [expr-lang](https://expr-lang.org/) expression, a safe, fast, and intuitive expression evaluator.
293329

@@ -327,7 +363,7 @@ label:
327363
| uniq()
328364
```
329365

330-
#### `label.color` (required)
366+
#### `label[].color` (required)
331367

332368
> [!NOTE]
333369
> When used on `strategy: generate` labels, all generated labels will have the same color.
@@ -336,7 +372,7 @@ label:
336372

337373
You can either provide your own `#hex` value or use the [Twitter Bootstrap color variables](https://getbootstrap.com/docs/5.3/customize/color/#all-colors), for example `$blue-500` and `$teal`.
338374

339-
#### `label.description` (optional)
375+
#### `label[].description` (optional)
340376

341377
> [!NOTE]
342378
> When used on `strategy: generate` labels, all generated labels will have the same description.
@@ -345,14 +381,14 @@ An optional key that control the `description` field for the label within GitLab
345381

346382
Descriptions are shown in the User Interface when you hover any label.
347383

348-
#### `label.priority` (optional)
384+
#### `label[].priority` (optional)
349385

350386
> [!NOTE]
351387
> When used on `strategy: generate` labels, all generated labels will have the same priority.
352388

353389
An optional key that controls the [label `priority`](https://docs.gitlab.com/ee/user/project/labels.html#set-label-priority).
354390

355-
#### `label.skip_if` (optional)
391+
#### `label[].skip_if` (optional)
356392

357393
An optional key controlling if the label should be skipped (meaning no removal or adding of labels).
358394

pkg/scm/gitlab/client_actioner.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ func (c *Client) ApplyStep(ctx context.Context, update *scm.UpdateMergeRequestOp
2828
case "reopen":
2929
update.StateEvent = gitlab.Ptr("reopen")
3030

31-
case "discussion_locked":
31+
case "lock_discussion":
3232
update.DiscussionLocked = gitlab.Ptr(true)
3333

34-
case "discussion_unlocked":
34+
case "unlock_discussion":
3535
update.DiscussionLocked = gitlab.Ptr(false)
3636

3737
case "approve":

0 commit comments

Comments
 (0)