Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workflow_dispatch use workflow from trigger branch #33098

Merged
merged 12 commits into from
Jan 5, 2025

Conversation

ChristopherHX
Copy link
Contributor

@ChristopherHX ChristopherHX commented Jan 3, 2025

  • htmx updates the input form on branch switch
  • add workflow warning to dispatch modal
  • use name if description of input is empty
  • show error if workflow_dispatch not available on branch

Closes #33073
Closes #33099

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jan 3, 2025
@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jan 3, 2025
@github-actions github-actions bot added modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files labels Jan 3, 2025
@ChristopherHX
Copy link
Contributor Author

ChristopherHX commented Jan 3, 2025

I request feedback, e.g. a new name for workflow-dispatch-inputs.

Is there a blocker of using a branch specific workflows like discussed in? #33073

This change makes it more like how it is in GitHub Actions.

Warning

this is the first time I ever touched the code of both htmx and the gitea web ui
As 1.23 is in rc already, is it even possible for such a breaking change to be included

Further problem I noticed while testing this, if I leave description blank only the value selector is visible. Open a new bug report soon and eventually open a PR as well

See Demos (Updated 4 Jan 2025 (2))

  • Showing an error if workflow doesn't exist on branch (problem only after submit, could not yet figure out how to add this to the template)
  • Showing success to queue non default branch
  • Showing inputs change per branch
  • Showing workflow warning of respective branch in dispatch modal
Bildschirmaufnahme.2025-01-04.um.22.49.05.mov

Screenshot of correctly passed inputs to non default workflow:

Bildschirmfoto 2025-01-03 um 23 11 32

My test instance just had an on: workflow_dispatch on the default branch without any inputs

@ChristopherHX
Copy link
Contributor Author

For reference I used the following workflows both same file:

Default branch

on: workflow_dispatch
jobs:
  _:
    runs-on: ubuntu-latest
    steps:
    - run: ${{ tojson(inputs) }}
      shell: cat {0}

Non default branch

on:
  workflow_dispatch:
    inputs:
      test-a:
        type: boolean
      test-b:
        type: choice
        options:
        - a
        - b
        - c
        - d
      test-c:
        description: One with description!
        type: boolean
jobs:
  _:
    runs-on: windows-latest
    steps:
    - run: ${{ tojson(inputs) }}
      shell: cat {0}

* htmx updates the input form on branch switch
* add workflow warning to dispatch modal
* use name if description of input is empty
* hide submit on workflow not found
@wxiaoguang
Copy link
Contributor

I will make some changes

@ChristopherHX
Copy link
Contributor Author

Feel free to do so :)

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Jan 4, 2025

Made some changes (I haven't really tested since I am not sure whether it looks good):

  1. introduce prepareWorkflowDispatchTemplate and prepareWorkflowList, then we do not need to use a lot of if blocks
  2. add repo.MustBeNotEmpty middleware, then we do not need to check repo.IsEmpty
  3. introduce CurWorkflowExists, not sure whether it is what you means
  4. use or instead of Iif, or is simpler

By the way, if you'd like to make the text center-aligned, I think you could just add a tw-text-center class to the ui message

@ChristopherHX
Copy link
Contributor Author

4. use or instead of Iif, or is simpler

I looked for coalesce and didn't notice we have a javascript like or 👍

3. introduce CurWorkflowExists, not sure whether it is what you means

This sounds like what I need.

By the way, if you'd like to make the text center-aligned, I think you could just add a tw-text-center class to the ui message

I technically just copied the html I found when triggering the workflow_dispatch.

So now I would change the error depending on CurWorkflowExists and add some new en-us locale definition

@wxiaoguang
Copy link
Contributor

Thank you for confirming, I think I have finished my changes at the moment.

* fix typo
* replace Submit with Run Workflow
* add actions.workflow.has_no_workflow_dispatch item
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jan 5, 2025
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jan 5, 2025
@wxiaoguang
Copy link
Contributor

Is there anything need to improve? If no, let's merge.

(wait for a while for confirmation)

@wxiaoguang wxiaoguang added this to the 1.24.0 milestone Jan 5, 2025
@wxiaoguang wxiaoguang added the type/enhancement An improvement of existing functionality label Jan 5, 2025
@ChristopherHX
Copy link
Contributor Author

ChristopherHX commented Jan 5, 2025

I checked again, everything on my TODO list is solved and confirmed this works as expected from my side

@wxiaoguang wxiaoguang merged commit 4237736 into go-gitea:main Jan 5, 2025
26 checks passed
zjjhot added a commit to zjjhot/gitea that referenced this pull request Jan 6, 2025
* giteaofficial/main:
  [skip ci] Updated translations via Crowdin
  Fix dropdown menu header and mobile view (go-gitea#33108)
  workflow_dispatch use workflow from trigger branch (go-gitea#33098)
  [skip ci] Updated translations via Crowdin
  Trivial fixes (go-gitea#33103)
  Fix empty git repo handling logic (go-gitea#33101)
  Refactor legacy line-number and scroll code (go-gitea#33094)
  Use `Project-URL` metadata field to get a PyPI package's homepage URL (go-gitea#33089)
  Clean up legacy form CSS styles (go-gitea#33081)
  [skip ci] Updated translations via Crowdin
  add myself to maintainers (go-gitea#33088)
  Make Gitea always use its internal config, ignore `/etc/gitconfig` (go-gitea#33076)
  Fix "stop time tracking button" on navbar (go-gitea#33084)
  Fix bleve fuzziness search (go-gitea#33078)
  Try to fix ACME directory problem (go-gitea#33072)
  Refactor env var related code (go-gitea#33075)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/go Pull requests that update Go code modifies/templates This PR modifies the template files modifies/translation size/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/enhancement An improvement of existing functionality
Projects
None yet
4 participants