You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gitea/modules
胖梁 36232b69db
Actions support workflow dispatch event (#28163)
fix #23668 

My plan:
* In the `actions.list` method, if workflow is selected and IsAdmin,
check whether the on event contains `workflow_dispatch`. If so, display
a `Run workflow` button to allow the user to manually trigger the run.
* Providing a form that allows users to select target brach or tag, and
these parameters can be configured in yaml
* Simple form validation, `required` input cannot be empty
* Add a route `/actions/run`, and an `actions.Run` method to handle
* Add `WorkflowDispatchPayload` struct to pass the Webhook event payload
to the runner when triggered, this payload carries the `inputs` values
and other fields, doc: [workflow_dispatch
payload](https://docs.github.com/en/webhooks/webhook-events-and-payloads#workflow_dispatch)

Other PRs
* the `Workflow.WorkflowDispatchConfig()` method still return non-nil
when workflow_dispatch is not defined. I submitted a PR
https://gitea.com/gitea/act/pulls/85 to fix it. Still waiting for them
to process.

Behavior should be same with github, but may cause confusion. Here's a
quick reminder.
*
[Doc](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch)
Said: This event will `only` trigger a workflow run if the workflow file
is `on the default branch`.
* If the workflow yaml file only exists in a non-default branch, it
cannot be triggered. (It will not even show up in the workflow list)
* If the same workflow yaml file exists in each branch at the same time,
the version of the default branch is used. Even if `Use workflow from`
selects another branch


![image](https://github.com/go-gitea/gitea/assets/3114995/4bf596f3-426b-48e8-9b8f-0f6d18defd79)
```yaml
name: Docker Image CI

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
      environment:
        description: 'Environment to run tests against'
        type: environment
        required: true
        default: 'environment values'
      number_required_1:
        description: 'number '
        type: number
        required: true
        default: '100'
      number_required_2:
        description: 'number'
        type: number
        required: true
        default: '100'
      number_required_3:
        description: 'number'
        type: number
        required: true
        default: '100'
      number_1:
        description: 'number'
        type: number
        required: false
      number_2:
        description: 'number'
        type: number
        required: false
      number_3:
        description: 'number'
        type: number
        required: false

env:
  inputs_logLevel:              ${{ inputs.logLevel }}
  inputs_tags:                  ${{ inputs.tags }}
  inputs_boolean_default_true:  ${{ inputs.boolean_default_true }}
  inputs_boolean_default_false: ${{ inputs.boolean_default_false }}
  inputs_environment:           ${{ inputs.environment }}
  inputs_number_1:              ${{ inputs.number_1  }}
  inputs_number_2:              ${{ inputs.number_2  }}
  inputs_number_3:              ${{ inputs.number_3  }}
  inputs_number_required_1:     ${{ inputs.number_required_1  }}
  inputs_number_required_2:     ${{ inputs.number_required_2  }}
  inputs_number_required_3:     ${{ inputs.number_required_3  }}

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - run: ls -la
      - run: env | grep inputs
      - run: echo ${{ inputs.logLevel }}
      - run: echo ${{ inputs.boolean_default_false }}
```

![image](https://github.com/go-gitea/gitea/assets/3114995/a58a842d-a0ff-4618-bc6d-83a9596d07c8)

![image](https://github.com/go-gitea/gitea/assets/3114995/44a7cca5-7bd4-42a9-8723-91751a501c88)

---------

Co-authored-by: TKaxv_7S <954067342@qq.com>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Denys Konovalov <kontakt@denyskon.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
6 months ago
..
actions Support compression for Actions logs (#31761) 6 months ago
activitypub Upgrade to golangci-lint@v1.55.0 (#27756) 1 year ago
analyze Rename code_langauge.go to code_language.go (#26377) 2 years ago
assetfs Use `Set[Type]` instead of `map[Type]bool/struct{}`. (#26804) 1 year ago
auth Add Passkey login support (#31504) 7 months ago
avatar Use `crypto/sha256` (#29386) 11 months ago
badge Implement actions badge svgs (#28102) 11 months ago
base fix OIDC introspection authentication (#31632) 6 months ago
cache Add cache test for admins (#31265) 8 months ago
charset Render embedded code preview by permlink in markdown (#30234) 10 months ago
container Allow disabling authentication related user features (#31535) 7 months ago
csv Render embedded code preview by permlink in markdown (#30234) 10 months ago
dump Refactor "dump" sub-command (#30240) 10 months ago
emoji Update emoji set to Unicode 15 (#25595) 2 years ago
eventsource Final round of `db.DefaultContext` refactor (#27587) 1 year ago
generate Refactor JWT secret generating & decoding code (#29172) 12 months ago
git Fix `IsObjectExist` with gogit (#31790) 6 months ago
gitgraph More `db.DefaultContext` refactor (#27265) 1 year ago
gitrepo Use repo as of renderctx's member rather than a repoPath on metas (#29222) 8 months ago
graceful Remove unused error in graceful manager (#29871) 11 months ago
hcaptcha Consume hcaptcha and pwn deps (#22610) 2 years ago
highlight Add option to disable ambiguous unicode characters detection (#28454) 1 year ago
hostmatcher Support allowed hosts for webhook to work with proxy (#27655) 1 year ago
html Refactor backend SVG package and add tests (#26335) 2 years ago
httpcache Also match weakly validated ETags (#28957) 1 year ago
httplib Fix duplicate sub-path for avatars (#31365) 8 months ago
indexer Properly filter issue list given no assignees filter (#31522) 6 months ago
issue/template Support issue template assignees (#31083) 6 months ago
json Replace `interface{}` with `any` (#25686) 2 years ago
label Make label templates have consistent behavior and priority (#23749) 2 years ago
lfs Distinguish LFS object errors to ignore missing objects during migration (#31702) 6 months ago
log Add some tests to clarify the "must-change-password" behavior (#30693) 9 months ago
markup Fix raw wiki links (#31825) 6 months ago
mcaptcha Implement FSFE REUSE for golang files (#21840) 2 years ago
metrics Rename project board -> column to make the UI less confusing (#30170) 8 months ago
migration Refactor locale&string&template related code (#29165) 12 months ago
nosql Update tool dependencies, lock govulncheck and actionlint (#25655) 2 years ago
optional Resolve lint for unused parameter and unnecessary type arguments (#30750) 9 months ago
options Use a general approach to access custom/static/builtin assets (#24022) 2 years ago
packages Support compression for Actions logs (#31761) 6 months ago
paginator Use more specific test methods (#24265) 2 years ago
pprof Implement FSFE REUSE for golang files (#21840) 2 years ago
private Move database operations of merging a pull request to post receive hook and add a transaction (#30805) 9 months ago
process Update misspell to 0.5.1 and add `misspellings.csv` (#30573) 9 months ago
proxy Use proxy for pull mirror (#22771) 2 years ago
proxyprotocol Implement FSFE REUSE for golang files (#21840) 2 years ago
public Refactor CORS handler (#28587) 1 year ago
queue Fix queue test (#30646) 9 months ago
recaptcha Implement FSFE REUSE for golang files (#21840) 2 years ago
references Refactor to use UnsafeStringToBytes (#31358) 8 months ago
regexplru Upgrade go dependencies (#25819) 2 years ago
repository Distinguish LFS object errors to ignore missing objects during migration (#31702) 6 months ago
secret Use `crypto/sha256` (#29386) 11 months ago
session Improve oauth2 client "preferred username field" logic and the error handling (#30622) 9 months ago
setting Support compression for Actions logs (#31761) 6 months ago
sitemap Fix sitemap (#22272) 2 years ago
ssh Remove SSH workaround (#27893) 1 year ago
storage Enable `unparam` linter (#31277) 8 months ago
structs Actions support workflow dispatch event (#28163) 6 months ago
svg Refactor markdown attention render (#29984) 11 months ago
sync Implement FSFE REUSE for golang files (#21840) 2 years ago
system Refactor to use UnsafeStringToBytes (#31358) 8 months ago
templates Refactor names (#31405) 8 months ago
test Remove sub-path from container registry realm (#31293) 8 months ago
testlogger Replace `interface{}` with `any` (#25686) 2 years ago
timeutil Refactor "dump" sub-command (#30240) 10 months ago
translation Render embedded code preview by permlink in markdown (#30234) 10 months ago
turnstile Add new captcha: cloudflare turnstile (#22369) 2 years ago
typesniffer Detect ogg mime-type as audio or video (#26494) 1 year ago
updatechecker Replace more db.DefaultContext (#27628) 1 year ago
uri Implement FSFE REUSE for golang files (#21840) 2 years ago
user Implement FSFE REUSE for golang files (#21840) 2 years ago
util Refactor to use UnsafeStringToBytes (#31358) 8 months ago
validation Check blocklist for emails when adding them to account (#26812) 1 year ago
web Refactor names (#31405) 8 months ago
webhook Fix schedule tasks bugs (#28691) 1 year ago
zstd Support compression for Actions logs (#31761) 6 months ago