actions: add an example for workflow-dispatch

/repos/{owner}/{repo}/actions/workflows/{workflowname}/dispatches

* fails if the required inputs are not provided
* sets defaults to inputs that are not provided

The type of inputs are only used for building the web UI interface,
not for validation. All values are strings.
This commit is contained in:
Earl Warren 2024-07-04 20:15:32 +02:00
parent 64489247aa
commit 05a341e201
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
4 changed files with 126 additions and 0 deletions

View file

@ -0,0 +1,57 @@
on:
workflow_dispatch:
inputs:
logLevel:
description: 'Log Level'
required: true
default: 'warning'
type: choice
options:
- info
- warning
- debug
tags:
description: 'Test scenario tags'
required: false
type: boolean
boolean_default_true:
description: 'Test scenario tags'
required: true
type: boolean
default: true
boolean_default_false:
description: 'Test scenario tags'
required: false
type: boolean
default: false
number1_default:
description: 'Number w. default'
default: '100'
type: number
number2:
description: 'Number w/o. default'
type: number
string1_default:
description: 'String w. default'
default: 'Hello world'
type: string
string2:
description: 'String w/o. default'
required: true
type: string
jobs:
test:
runs-on: docker
container:
image: code.forgejo.org/oci/debian:bookworm
options: "--volume /srv/example:/srv/example"
steps:
- name: save and display context
run: |
d=/srv/example/workflow-dispatch/contexts/$GITHUB_EVENT_NAME
mkdir -p $d
tee $d/github <<'EOF'
${{ toJSON(github) }}
EOF