Skip to content

Conversation

@lunny
Copy link
Member

@lunny lunny commented Mar 31, 2024

This PR introduces project workflows, allowing users to configure event-based automations directly from the UI.
Users can define filters and actions for each workflow event, and duplicate existing events when needed.

Concepts

  • Event - An Event defines when a workflow should be triggered. It represents specific activities such as an issue being opened, a pull request being merged, or a project column being changed.
  • Filter - A Filter refines when an event should take effect. It allows users to specify conditions like issue type, labels, or project columns to ensure actions only run in targeted scenarios.
  • Action - An Action defines what happens when the event and filters match. It performs operations such as adding labels, moving issues between columns, or changing the issue or pull request state.

Available Events

Currently, the following nine events are supported:

  • On issues/pull requests opened
  • On issues/pull requests closed
  • On issues/pull requests reopened
  • On issues/pull requests was added to the project
  • On issues/pull requests was removed to the project
  • On issues/pull requests' column was changed
  • On code changes requested
  • On code review approved
  • On pull request merged

Each event type supports its own set of filters and actions.

Available Filters

There are four types of filters that can be configured for an event:

  • Apply to - Specify the target type: issues only, pull requests only, or issues and pull requests.
  • Labels - Trigger the event only if the issue or pull request contains one or more specified labels.
  • Move from column - Filter events based on the original project column.
  • Move to column - Filter events based on the destination project column.

Available Actions

There are four types of actions that can be executed when an event is triggered:

  • Add labels - Automatically add one or more labels to the issue or pull request.
  • Remove labels - Remove one or more specified labels.
  • Move to column - Move the issue or pull request to a designated project column.
  • Issue state - Change the state by closing or reopening the issue or pull request.

Enable/Disable an event workflow

Each event workflow can be individually enabled or disabled. When disabled, the workflow will be ignored even if the event occurs. This feature is useful when you want to temporarily stop certain automated actions without deleting the workflow configuration.

Clone an event workflow

When you need multiple workflows for the same event, you can clone an existing event to create a new one with different filters and actions. This allows you to customize how the same event behaves under different conditions, making workflows more flexible and powerful.

Screen shots

  • View mode
image
  • Edit mode
image
  • Dark theme
image

@lunny lunny added the type/feature Completely new functionality. Can only be merged if feature freeze is not active. label Mar 31, 2024
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 31, 2024
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Mar 31, 2024
@lunny
Copy link
Member Author

lunny commented Apr 19, 2024

I'm now hesitate to add this feature because looks like some actions can do the same things. Like https://docs.github.com/en/issues/planning-and-tracking-with-projects/automating-your-project/automating-projects-using-actions and more third-party actions can do it easier.

@rohrschacht
Copy link

I would really like to see this merged, I am waiting for the ability to automatically set a project for a new issue via the issue template (#25028). GitHub provides this through an "org-name/BOARD_ID" syntax as announced here. I think having to set up an action for that (which would also require to set up a runner?) is quite cumbersome for such a simple feature.

@lunny lunny added this to the 1.23.0 milestone May 7, 2024
@silkentrance
Copy link
Contributor

silkentrance commented May 31, 2024

I'm now hesitate to add this feature because looks like some actions can do the same things. Like https://docs.github.com/en/issues/planning-and-tracking-with-projects/automating-your-project/automating-projects-using-actions and more third-party actions can do it easier.

@lunny

I do not know, but firing up multiple containers to just set a specific label or remove a label, or even re-open or close an issue as part of the workflow seems to be overkill to me, what do you think?

@thekk1
Copy link

thekk1 commented Aug 1, 2024

I'm now hesitate to add this feature because looks like some actions can do the same things. Like https://docs.github.com/en/issues/planning-and-tracking-with-projects/automating-your-project/automating-projects-using-actions and more third-party actions can do it easier.

What's the status here now? This is quite a wanted feature.
Do you have just a feeling about this or a specific good reason?
Running multiple containers for just moving around a Issue is for sure not the best practice.

@lunny
Copy link
Member Author

lunny commented Aug 1, 2024

I'm now hesitate to add this feature because looks like some actions can do the same things. Like https://docs.github.com/en/issues/planning-and-tracking-with-projects/automating-your-project/automating-projects-using-actions and more third-party actions can do it easier.

What's the status here now? This is quite a wanted feature. Do you have just a feeling about this or a specific good reason? Running multiple containers for just moving around a Issue is for sure not the best practice.

Yes, this is a good reason to use the internal implementation rather than CI/CD. I will continue this work.

@thekk1
Copy link

thekk1 commented Aug 1, 2024

I'm now hesitate to add this feature because looks like some actions can do the same things. Like https://docs.github.com/en/issues/planning-and-tracking-with-projects/automating-your-project/automating-projects-using-actions and more third-party actions can do it easier.

What's the status here now? This is quite a wanted feature. Do you have just a feeling about this or a specific good reason? Running multiple containers for just moving around a Issue is for sure not the best practice.

Yes, this is a good reason to use the internal implementation rather than CI/CD. I will continue this work.

Great, thx for your feedback. I am really looking forward to it.

@thekk1
Copy link

thekk1 commented Sep 3, 2024

As far as I understand the description, this will depend on Workflows?
So Actions has to be enabled?
This would be a problem for us, because the workflows in our repos are for the environment of our customers and Actions are always disabled because they will not work in our environment.

@lunny
Copy link
Member Author

lunny commented Sep 3, 2024

As far as I understand the description, this will depend on Workflows? So Actions has to be enabled? This would be a problem for us, because the workflows in our repos are for the environment of our customers and Actions are always disabled because they will not work in our environment.

No. This is project workflow which is different from Actions workflow.

@lunny lunny removed this from the 1.23.0 milestone Sep 7, 2024
@lunny
Copy link
Member Author

lunny commented Sep 12, 2024

And what's better? Storing the workflows in the special YAML files on the default branch or storing them in the database? This is a block to prevent me from continuing the work.

@thekk1
Copy link

thekk1 commented Sep 12, 2024

I would purpose to store them in the database. Branches are for code changes and depending stuff but this is a projekt management feature that is specific for gitea. i.e.: If you mirror your code to an other git system like github the projekt workflows are only garbage there.

@eeyrjmr
Copy link
Contributor

eeyrjmr commented Sep 12, 2024

I would purpose to store them in the database. Branches are for code changes and depending stuff but this is a projekt management feature that is specific for gitea. i.e.: If you mirror your code to an other git system like github the projekt workflows are only garbage there.

but storing in the db will require some form of UI to create/edit.
Right now .gitea/* is used to store issue templates and all of that is "garbage" if you were to mirror into github since github only looks in .github thus that objection is moot.

@thekk1
Copy link

thekk1 commented Sep 12, 2024

but storing in the db will require some form of UI to create/edit. Right now .gitea/* is used to store issue templates and all of that is "garbage" if you were to mirror into github since github only looks in .github thus that objection is moot.

For my defence I didn't know about the templates and the storage path. In that case I would agree to that argument.

@Woonhyung59
Copy link

Thank you for working on this important feature. Many users, including myself, are eagerly anticipating the addition of project workflows to Gitea. This functionality would greatly enhance project management capabilities within the platform.

@lunny lunny added this to the 1.24.0 milestone Dec 17, 2024
@lunny lunny mentioned this pull request Dec 17, 2024
@steveepreston
Copy link

@lunny ❤️

@lunny lunny marked this pull request as ready for review October 27, 2025 17:20
@lunny
Copy link
Member Author

lunny commented Oct 27, 2025

This is ready to review now.

@tpokorra
Copy link

That looks great, @lunny! Thank you!

I did compile it and run it.
When I try to save a workflow, I get an error 500, no matter which default workflow I use:

2025/10/28 16:10:14 .../projects/workflows.go:462:WorkflowsPost() [E] CreateWorkflow: pq: invalid input syntax for type integer: "item_column_changed"
2025/10/28 16:10:14 HTTPRequest [I] router: completed POST /admin_gitea/test/projects/1/workflows/item_column_changed for 87.121.195.161:0, 500 Internal Server Error in 24.4ms @ projects/workflows.go:402(projects.WorkflowsPost)
2025/10/28 16:12:26 HTTPRequest [I] router: completed GET /admin_gitea/test/projects/1/workflows/columns for 87.121.195.161:0, 200 OK in 28.2ms @ projects/workflows.go:315(projects.Workflows)
2025/10/28 16:12:26 HTTPRequest [I] router: completed GET /admin_gitea/test/projects/1/workflows/labels for 87.121.195.161:0, 200 OK in 22.5ms @ projects/workflows.go:315(projects.Workflows)
2025/10/28 16:12:38 .../projects/workflows.go:462:WorkflowsPost() [E] CreateWorkflow: pq: invalid input syntax for type integer: "pull_request_merged"
2025/10/28 16:12:38 HTTPRequest [I] router: completed POST /admin_gitea/test/projects/1/workflows/pull_request_merged for 87.121.195.161:0, 500 Internal Server Error in 30.2ms @ projects/workflows.go:402(projects.WorkflowsPost)

I did not try anything special.
It happened without any selections, or with selected columns/labels.

Here is the POST data:

{"event_id":"pull_request_merged","filters":{"issue_type":"","source_column":"","target_column":"","labels":[]},"actions":{"column":"6","add_labels":["6"],"remove_labels":["5"],"issue_state":""}}

@lunny
Copy link
Member Author

lunny commented Oct 28, 2025

That looks great, @lunny! Thank you!

I did compile it and run it. When I try to save a workflow, I get an error 500, no matter which default workflow I use:

2025/10/28 16:10:14 .../projects/workflows.go:462:WorkflowsPost() [E] CreateWorkflow: pq: invalid input syntax for type integer: "item_column_changed"
2025/10/28 16:10:14 HTTPRequest [I] router: completed POST /admin_gitea/test/projects/1/workflows/item_column_changed for 87.121.195.161:0, 500 Internal Server Error in 24.4ms @ projects/workflows.go:402(projects.WorkflowsPost)
2025/10/28 16:12:26 HTTPRequest [I] router: completed GET /admin_gitea/test/projects/1/workflows/columns for 87.121.195.161:0, 200 OK in 28.2ms @ projects/workflows.go:315(projects.Workflows)
2025/10/28 16:12:26 HTTPRequest [I] router: completed GET /admin_gitea/test/projects/1/workflows/labels for 87.121.195.161:0, 200 OK in 22.5ms @ projects/workflows.go:315(projects.Workflows)
2025/10/28 16:12:38 .../projects/workflows.go:462:WorkflowsPost() [E] CreateWorkflow: pq: invalid input syntax for type integer: "pull_request_merged"
2025/10/28 16:12:38 HTTPRequest [I] router: completed POST /admin_gitea/test/projects/1/workflows/pull_request_merged for 87.121.195.161:0, 500 Internal Server Error in 30.2ms @ projects/workflows.go:402(projects.WorkflowsPost)

I did not try anything special. It happened without any selections, or with selected columns/labels.

Here is the POST data:

{"event_id":"pull_request_merged","filters":{"issue_type":"","source_column":"","target_column":"","labels":[]},"actions":{"column":"6","add_labels":["6"],"remove_labels":["5"],"issue_state":""}}

Thank you for the feedback — I’ve fixed the issue.
Please test it again. Note that in your test environment, you’ll need to:
1. Update the version number to 324.
2. Manually delete the project_workflow table.
3. Run the test again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. modifies/frontend modifies/go Pull requests that update Go code modifies/migrations modifies/templates This PR modifies the template files modifies/translation topic/projects type/feature Completely new functionality. Can only be merged if feature freeze is not active.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Kanban automation using labels Allow kanban/project board to set labels on column switch [Feature] Add automated project board