forgejo/templates/repo
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
..
actions Add support for workflow_dispatch (#3334) 2024-06-28 05:17:11 +00:00
branch Don't include link of deleted branch when listing branches (#31028) 2024-05-26 18:45:23 +02:00
cite Fix Citation modal responsiveness and clipboard copy (#29799) 2024-03-20 08:46:29 +01:00
code Fix overflow on push notification (#31179) 2024-06-09 11:13:39 +02:00
diff Fix the wrong line number in the diff view page when expanded twice. (#31431) 2024-06-23 12:48:08 +02:00
editor Convert max file name length to 255 (#30489) 2024-04-21 11:53:41 +02:00
find Migrate gt-hidden to tw-hidden (#30046) 2024-03-30 07:17:29 +01:00
graph Size/gap changes and cleanup in commit graph (#4214) 2024-06-24 18:59:57 +00:00
issue Clarify author label in tooltip 2024-06-25 18:30:06 +05:00
migrate Fix and improve repo visibility checkbox when FORCE_PRIVATE is on (#3786) 2024-05-16 05:51:55 +00:00
projects Migrate margin and padding helpers to tailwind (#30043) 2024-03-30 07:17:29 +01:00
pulls Improve diff stats bar (#30669) 2024-04-28 15:39:01 +02:00
release Replace gt-word-break with tw-break-anywhere 2024-06-11 08:57:27 +05:00
settings Replace gt-word-break with tw-break-anywhere 2024-06-11 08:57:27 +05:00
tag Adjust the signed tag verification line 2024-04-02 23:02:34 +02:00
wiki Replace gt-word-break with tw-break-anywhere 2024-06-11 08:57:27 +05:00
activity.tmpl Show repo activities even if only code unit active or git repo is empty but issue is active (#3455) 2024-04-28 13:47:52 +00:00
admin_flags.tmpl [FEAT] Repository flags 2024-02-05 16:09:42 +01:00
blame.tmpl Fix the link for .git-blame-ignore-revs bypass (#31432) 2024-06-23 13:07:53 +02:00
branch_dropdown.tmpl Fix long branch name overflows (https://github.com/go-gitea/gitea/pull/30345) 2024-05-24 22:11:37 +05:00
clone_buttons.tmpl Refactor clone-panel styles (#29861) 2024-03-26 19:04:24 +01:00
clone_script.tmpl Customizable "Open with" applications for repository clone (#29320) 2024-03-23 11:58:54 +01:00
code_frequency.tmpl Implement code frequency graph (#29191) 2024-02-26 22:30:26 +01:00
commit_load_branches_and_tags.tmpl Migrate gt-hidden to tw-hidden (#30046) 2024-03-30 07:17:29 +01:00
commit_page.tmpl Various improvements for long file and commit names (#30374) 2024-04-15 20:01:35 +02:00
commit_status.tmpl Restore warning commit status (#27504) 2023-10-08 22:16:06 +00:00
commit_statuses.tmpl Replace 10 more gt- classes with tw- (#29945) 2024-03-26 19:04:27 +01:00
commits.tmpl Migrate margin and padding helpers to tailwind (#30043) 2024-03-30 07:17:29 +01:00
commits_list.tmpl [PORT] gitea#30396: Fix author name alignment in commits table 2024-04-15 20:09:34 +02:00
commits_list_small.tmpl Fix some UI regressions for commit list (#30920) 2024-05-12 20:03:10 +02:00
commits_search_dropdown.tmpl Unify search boxes (#29530) 2024-03-20 12:31:05 +00:00
commits_table.tmpl Migrate margin and padding helpers to tailwind (#30043) 2024-03-30 07:17:29 +01:00
contributors.tmpl Fix Activity Page Contributors dropdown (#31264) 2024-06-18 20:05:23 +02:00
create.tmpl Fix and improve repo visibility checkbox when FORCE_PRIVATE is on (#3786) 2024-05-16 05:51:55 +00:00
create_helper.tmpl Remove incorrect and unnecessary Escape from templates (#29394) 2024-02-26 22:30:27 +01:00
empty.tmpl Migrate margin and padding helpers to tailwind (#30043) 2024-03-30 07:17:29 +01:00
file_info.tmpl Remove obsolete CSS text classes (#30576) 2024-04-28 15:39:00 +02:00
flags.tmpl Migrate margin and padding helpers to tailwind (#30043) 2024-03-30 07:17:29 +01:00
forks.tmpl Migrate margin and padding helpers to tailwind (#30043) 2024-03-30 07:17:29 +01:00
graph.tmpl Size/gap changes and cleanup in commit graph (#4214) 2024-06-24 18:59:57 +00:00
header.tmpl Reorder repo tabs (#4139) 2024-06-16 12:36:41 +00:00
header_fork.tmpl Migrate margin and padding helpers to tailwind (#30043) 2024-03-30 07:17:29 +01:00
home.tmpl Replace gt-word-break with tw-break-anywhere 2024-06-11 08:57:27 +05:00
icon.tmpl Replace 10 more gt- classes with tw- (#29945) 2024-03-26 19:04:27 +01:00
latest_commit.tmpl Fix DEFAULT_SHOW_FULL_NAME=false has no effect in commit list and commit graph page (#30096) 2024-04-07 10:52:45 +02:00
navbar.tmpl Implement recent commits graph (#29210) 2024-02-26 22:30:26 +01:00
packages.tmpl Fix inconsistent user profile layout across tabs (#25625) 2023-07-06 18:59:24 +00:00
pulse.tmpl Pulse page improvements (#30149) 2024-04-21 11:08:33 +02:00
recent_commits.tmpl Implement recent commits graph (#29210) 2024-02-26 22:30:26 +01:00
release_tag_header.tmpl Fix localization of release/tag counters on releases page 2024-05-29 22:46:36 +05:00
search.tmpl Unify search boxes (#29530) 2024-03-20 12:31:05 +00:00
search_name.tmpl
shabox_badge.tmpl cleanup locale function usage (#27227) 2023-09-24 20:31:58 +00:00
star_unstar.tmpl Further consistency in the repo header 2024-03-27 09:33:06 +01:00
sub_menu.tmpl Rename ByteSize to ReadableSize 2024-03-31 20:17:12 +05:00
unicode_escape_prompt.tmpl templates: remove superfluous SanitizeHTML 2024-03-11 23:36:58 +07:00
upload.tmpl Always use ctx.Locale.Tr inside templates (#27231) 2023-09-25 08:56:50 +00:00
user_cards.tmpl Add headers to follower lists 2024-06-19 11:53:59 +05:00
view_file.tmpl Fix border-radius on view, blame and code search (#30545) 2024-04-21 16:28:16 +02:00
view_list.tmpl Fix view of readme file in the home code page. (#30564) 2024-04-28 15:39:01 +02:00
watch_unwatch.tmpl Further consistency in the repo header 2024-03-27 09:33:06 +01:00
watchers.tmpl Fix user-cards format (#24428) 2023-04-29 15:43:01 -04:00