forgejo/tests/gitea-repositories-meta/user2
Mai-Lapyst 51735c415b Add support for workflow_dispatch (#3334)
Closes #2797

I'm aware of https://github.com/go-gitea/gitea/pull/28163 exists, but since I had it laying around on my drive and collecting dust, I might as well open a PR for it if anyone wants the feature a bit sooner than waiting for upstream to release it or to be a forgejo "native" implementation.

This PR Contains:
- Support for the `workflow_dispatch` trigger
- Inputs: boolean, string, number, choice

Things still to be done:
- [x] API Endpoint `/api/v1/<org>/<repo>/actions/workflows/<workflow id>/dispatches`
- ~~Fixing some UI bugs I had no time figuring out, like why dropdown/choice inputs's menu's behave weirdly~~ Unrelated visual bug with dropdowns inside dropdowns
- [x] Fix bug where opening the branch selection submits the form
- [x] Limit on inputs to render/process

Things not in this PR:
- Inputs: environment (First need support for environments in forgejo)

Things needed to test this:
- A patch for https://code.forgejo.org/forgejo/runner to actually consider the inputs inside the workflow.
  ~~One possible patch can be seen here: https://code.forgejo.org/Mai-Lapyst/runner/src/branch/support-workflow-inputs~~
  [PR](https://code.forgejo.org/forgejo/runner/pulls/199)

![image](/attachments/2db50c9e-898f-41cb-b698-43edeefd2573)

## Testing

- Checkout PR
- Setup new development runner with [this PR](https://code.forgejo.org/forgejo/runner/pulls/199)
- Create a repo with a workflow (see below)
- Go to the actions tab, select the workflow and see the notice as in the screenshot above
- Use the button + dropdown to run the workflow
  - Try also running it via the api using the `` endpoint
- ...
- Profit!

<details>
<summary>Example workflow</summary>

```yaml
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
    steps:
      - uses: actions/checkout@v3
      - run: whoami
      - run: cat /etc/issue
      - run: uname -a
      - run: date
      - run: echo ${{ inputs.logLevel }}
      - run: echo ${{ inputs.tags }}
      - env:
          GITHUB_CONTEXT: ${{ toJson(github) }}
        run: echo "$GITHUB_CONTEXT"
      - run: echo "abc"
```
</details>

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/3334
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Co-authored-by: Mai-Lapyst <mai-lapyst@noreply.codeberg.org>
Co-committed-by: Mai-Lapyst <mai-lapyst@noreply.codeberg.org>
2024-06-28 05:17:11 +00:00
..
commits_search_test.git Kd/ci playwright go test (#20123) 2022-09-02 15:18:23 -04:00
commitsonpr.git Add commits dropdown in PR files view and allow commit by commit review (#25528) 2023-07-28 21:18:12 +02:00
git_hooks_test.git Kd/ci playwright go test (#20123) 2022-09-02 15:18:23 -04:00
glob.git Kd/ci playwright go test (#20123) 2022-09-02 15:18:23 -04:00
lfs.git Test views of LFS files (#22196) 2022-12-23 07:41:56 +08:00
readme-test.git Test renderReadmeFile (#23185) 2023-03-09 09:24:23 +08:00
repo-release.git Remove git sample files and ignore them (#24271) 2023-04-22 20:29:29 +08:00
repo1.git Replace repo.namedBlob by git.TreeEntry. (#22898) 2023-03-15 16:51:39 -05:00
repo1.wiki.git Kd/ci playwright go test (#20123) 2022-09-02 15:18:23 -04:00
repo2.git Allow get release download files and lfs files with oauth2 token format (#26430) 2023-10-01 10:41:52 +00:00
repo15.git Kd/ci playwright go test (#20123) 2022-09-02 15:18:23 -04:00
repo16.git Kd/ci playwright go test (#20123) 2022-09-02 15:18:23 -04:00
repo20.git Use beforeCommit instead of baseCommit (#22949) 2023-02-20 11:56:07 +08:00
repo59.git [GITEA] Detect file rename and show in history 2024-02-05 16:09:40 +01:00
test_commit_revert.git tests: missing refs/ in bare repositories (#28844) 2024-01-19 15:12:21 +08:00
test_workflows.git Add support for workflow_dispatch (#3334) 2024-06-28 05:17:11 +00:00
utf8.git Kd/ci playwright go test (#20123) 2022-09-02 15:18:23 -04:00