mirror of
https://codeberg.org/forgejo/docs.git
synced 2024-11-21 17:36:59 -05:00
Document the on.workflow_dispatch event trigger
This commit is contained in:
parent
00102c44e2
commit
3817c7f5e2
1 changed files with 52 additions and 0 deletions
|
@ -615,6 +615,58 @@ on:
|
||||||
|
|
||||||
[Check out the example](https://code.forgejo.org/forgejo/end-to-end/src/branch/main/actions/example-cron/.forgejo/workflows/test.yml).
|
[Check out the example](https://code.forgejo.org/forgejo/end-to-end/src/branch/main/actions/example-cron/.forgejo/workflows/test.yml).
|
||||||
|
|
||||||
|
### `on.workflow_dispatch`
|
||||||
|
|
||||||
|
The `workflow_dispatch` events allows for manual triggering a workflow by either using the Forgejo UI, or the API with the `POST /repos/{owner}/{repo}/actions/workflows/{workflowname}/dispatches` endpoint. This event allows for inputs to be defined, which will get rendered in the Forgejo UI or read from the body of the API request.
|
||||||
|
|
||||||
|
Inputs are declared in the `inputs` sub-key, where each sub-key itself is an input. Each of those inputs need to have an `type`. These types can be:
|
||||||
|
|
||||||
|
- `choice`: A dropdown where the available options are defined as a list of strings with `options`
|
||||||
|
- `boolean`: A checkbox with the values of `true` or `false`
|
||||||
|
- `number`
|
||||||
|
- `string`
|
||||||
|
|
||||||
|
Additionally, every input can be made `required`, given an human-readable `description`, and an `default` value.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
logLevel:
|
||||||
|
description: 'Log Level'
|
||||||
|
required: true
|
||||||
|
default: 'warning'
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- info
|
||||||
|
- warning
|
||||||
|
- debug
|
||||||
|
boolean:
|
||||||
|
description: 'Boolean'
|
||||||
|
required: false
|
||||||
|
type: boolean
|
||||||
|
number:
|
||||||
|
description: 'Number'
|
||||||
|
default: '100'
|
||||||
|
type: number
|
||||||
|
string:
|
||||||
|
description: 'String'
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
```
|
||||||
|
|
||||||
|
Inputs then can be used inside the jobs with the `inputs` context:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: docker
|
||||||
|
steps:
|
||||||
|
- run: echo ${{ inputs.logLevel }}
|
||||||
|
```
|
||||||
|
|
||||||
|
[Check out the example](https://code.forgejo.org/forgejo/end-to-end/src/branch/main/actions/example-workflow-dispatch/.forgejo/workflows/test.yml).
|
||||||
|
|
||||||
### `env`
|
### `env`
|
||||||
|
|
||||||
Set environment variables that are available in the workflow in the `env` `context` and as regular environment variables.
|
Set environment variables that are available in the workflow in the `env` `context` and as regular environment variables.
|
||||||
|
|
Loading…
Reference in a new issue