aboutsummaryrefslogtreecommitdiffstats
path: root/services/actions
Commit message (Collapse)AuthorAgeFilesLines
* Refactor functions to reduce repopath expose (#33892)Lunny Xiao9 days1-2/+2
|
* Feature: Ephemeral action runners (#33570)ChristopherHX11 days2-1/+46
| | | | | | | | * This includes a runner mock test for hardend PickTask behavior like described in my proposal * Runner register ephemeral flag introduced in https://gitea.com/gitea/act_runner/pulls/649 Closes #32461
* Add workflow_job webhook (#33694)ChristopherHX14 days6-3/+45
| | | | | | | | | Provide external Integration information about the Queue lossly based on https://docs.github.com/en/webhooks/webhook-events-and-payloads?actionType=completed#workflow_job Naming conflicts between GitHub & Gitea are here, Blocked => Waiting, Waiting => Queued Rationale Enhancement for ephemeral runners management #33570
* Fix auto concurrency cancellation skips commit status updates (#33764)ChristopherHX2025-03-104-6/+26
| | | | | | | | * add missing commit status * conflicts with concurrency support Closes #33763 Co-authored-by: Giteabot <teabot@gitea.io>
* Refactor error system (#33771)wxiaoguang2025-03-031-5/+5
| | | It should not expose `util.SilentWrap` or construct it manually.
* Use test context in tests and new loop system in benchmarks (#33648)TheFox0x72025-02-201-2/+1
| | | | | | | | Replace all contexts in tests with go1.24 t.Context() --------- Co-authored-by: Giteabot <teabot@gitea.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Refactor error system (#33626)wxiaoguang2025-02-171-1/+1
|
* Refactor error system (#33610)wxiaoguang2025-02-161-2/+2
|
* Add a transaction to `pickTask` (#33543)Zettat1232025-02-121-0/+107
| | | | | | | | | | In the old `pickTask`, when getting secrets or variables failed, the task could get stuck in the `running` status (task status is `running` but the runner did not fetch the task). To fix this issue, these steps should be in one transaction. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Enhance routers for the Actions variable operations (#33547)Jason Song2025-02-111-9/+6
| | | | | | | | | | - Find the variable before updating or deleting - Move the main logic from `routers/web/repo/setting/variables.go` to `routers/web/shared/actions/variables.go`. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Giteabot <teabot@gitea.io>
* Feature: Support workflow event dispatch via API (#33545)wxiaoguang2025-02-111-0/+281
| | | | | | | | | Fix: https://github.com/go-gitea/gitea/issues/31765 (Re-open #32059) --------- Co-authored-by: Bence Santha <git@santha.eu> Co-authored-by: Bence Sántha <7604637+bencurio@users.noreply.github.com> Co-authored-by: Christopher Homberger <christopher.homberger@web.de>
* Revert "Feature: Support workflow event dispatch via API (#32059)" (#33541)wxiaoguang2025-02-102-316/+0
| | | This reverts commit 523751dc82bbb9d3f8d413f232e23ab0476eb4d4.
* Feature: Support workflow event dispatch via API (#32059)Bence Sántha2025-02-102-0/+316
| | | | | | | | | ref: https://github.com/go-gitea/gitea/issues/31765 --------- Signed-off-by: Bence Santha <git@santha.eu> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Christopher Homberger <christopher.homberger@web.de>
* Skip deletion error for action artifacts (#33476)wxiaoguang2025-02-021-6/+5
|
* Refactor user & avatar (#33433)wxiaoguang2025-01-301-1/+1
| | | | | 1. better GetPossibleUserByID logic 2. fix some function name & comment typos 3. do not re-generate avatar if one exists
* Move some Actions related functions from `routers` to `services` (#33280)Zettat1232025-01-153-3/+191
| | | | | | | | | | | | Move the main logic of `generateTaskContext` and `findTaskNeeds` to the `services` layer. This is a part of #32751, since we need the git context and `needs` to parse the concurrency expressions. --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Refactor RefName (#33234)wxiaoguang2025-01-131-4/+4
| | | And fix some FIXMEs
* Update status check for all supported on.pull_request.types in Gitea (#33117)yp053272025-01-081-1/+7
| | | | | | | | | | | | | | | | | | | | | | | Thanks @Zettat123 Follow #33116 Fix #33051 on.pull_request.types doc: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request on.pull_request.types added in this PR: ``` assigned, unassigned, review_requested, review_request_removed, milestoned, demilestoned, labeled, unlabeled ``` unsupported types in Gitea: ``` // Unsupported activity types: // converted_to_draft, ready_for_review, locked, unlocked, auto_merge_enabled, auto_merge_disabled, enqueued, dequeued ``` TODO: - [x] add test
* feat(action): issue change title notifications (#33050)Bo-Yi Wu2024-12-311-0/+8
| | | | | | | | | | | | | | | | | | | | | - Add `IssueChangeTitle` method to handle issue title changes - Add `notifyIssueChangeWithTitleOrContent` method to generalize notification handling for issue title or content changes action file as below: ```yaml name: Semantic Pull Request on: pull_request_target: types: [edited] ``` --------- Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com> Co-authored-by: Giteabot <teabot@gitea.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Use env GITEA_RUNNER_REGISTRATION_TOKEN as global runner token (#32946)wxiaoguang2024-12-232-3/+128
| | | | | | Fix #23703 When Gitea starts, it reads GITEA_RUNNER_REGISTRATION_TOKEN or GITEA_RUNNER_REGISTRATION_TOKEN_FILE to add registration token.
* Enable tenv and testifylint rules (#32852)TheFox0x72024-12-151-6/+6
| | | | Enables tenv and testifylint linters closes: https://github.com/go-gitea/gitea/issues/32842
* allow the actions user to login via the jwt token (#32527)Rowan Bohde2024-11-201-3/+8
| | | | | | | | | | | | | | | | We have some actions that leverage the Gitea API that began receiving 401 errors, with a message that the user was not found. These actions use the `ACTIONS_RUNTIME_TOKEN` env var in the actions job to authenticate with the Gitea API. The format of this env var in actions jobs changed with go-gitea/gitea/pull/28885 to be a JWT (with a corresponding update to `act_runner`) Since it was a JWT, the OAuth parsing logic attempted to parse it as an OAuth token, and would return user not found, instead of falling back to look up the running task and assigning it to the actions user. Make ACTIONS_RUNTIME_TOKEN in action runners could be used, attempting to parse Oauth JWTs. The code to parse potential old `ACTION_RUNTIME_TOKEN` was kept in case someone is running an older version of act_runner that doesn't support the Actions JWT.
* Add new event commit status creation and webhook implementation (#27151)Lunny Xiao2024-11-071-4/+2
| | | | | | | | | | | This PR introduces a new event which is similar as Github's. When a new commit status submitted, the event will be trigged. That means, now we can receive all feedback from CI/CD system in webhooks or other notify systems. ref: https://docs.github.com/en/webhooks/webhook-events-and-payloads#status Fix #20749
* Update scheduled tasks even if changes are pushed by "ActionsUser" (#32246)Zettat1232024-10-131-1/+9
| | | | | | | Fix #32219 --------- Co-authored-by: delvh <dev.lh@web.de>
* bump to go 1.23 (#31855)techknowlogick2024-09-101-1/+2
|
* Fix actions notify bug (#31866)Lunny Xiao2024-08-192-11/+16
| | | | Try to fix https://github.com/go-gitea/gitea/issues/31757#issuecomment-2295131062
* Clear up old Actions logs (#31735)Jason Song2024-08-021-9/+58
| | | | | | | | | | | | | | | | | Part of #24256. Clear up old action logs to free up storage space. Users will see a message indicating that the log has been cleared if they view old tasks. <img width="1361" alt="image" src="https://github.com/user-attachments/assets/9f0f3a3a-bc5a-402f-90ca-49282d196c22"> Docs: https://gitea.com/gitea/docs/pulls/40 --------- Co-authored-by: silverwind <me@silverwind.io>
* Move `registerActionsCleanup` to `initActionsTasks` (#31721)Jason Song2024-07-301-2/+1
| | | | | | | There's already `initActionsTasks`; it will avoid additional check for if Actions enabled to move `registerActionsCleanup` into it. And we don't really need `OlderThanConfig`.
* Support `pull_request_target` event for commit status (#31703)Zettat1232024-07-261-1/+6
| | | | | | | | | | | | Fix [act_runner #573](https://gitea.com/gitea/act_runner/issues/573) Before: ![image](https://github.com/user-attachments/assets/3944bf7f-7a60-4801-bcb3-5e158a180fda) After: ![image](https://github.com/user-attachments/assets/cadac944-40bd-4537-a9d9-e702b8bc1ece)
* Improve the handling of `jobs.<job_id>.if` (#31070)Zettat1232024-05-272-16/+16
| | | | | | | | | | | | | | | | | | | Fix #25897 Fix #30322 #29464 cannot handle some complex `if` conditions correctly because it only checks `always()` literally. In fact, it's not easy to evaluate the `if` condition on the Gitea side because evaluating it requires a series of contexts. But act_runner is able to evaluate the `if` condition before running the job (for more information, see [`gitea/act`](https://gitea.com/gitea/act/src/commit/517d11c67126bd97c88e2faabda0832fff482258/pkg/runner/run_context.go#L739-L753)) . So we can use act_runner to check the `if` condition. In this PR, how to handle a blocked job depends on its `needs` and `if`: - If not all jobs in `needs` completed successfully and the job's `if` is empty, set the job status to `StatusSkipped` - In other cases, the job status will be set to `StatusWaiting`, and then act_runner will check the `if` condition and run the job if the condition is met
* feat(api): enhance Actions Secrets Management API for repository (#30656)Bo-Yi Wu2024-04-261-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | - Add endpoint to list repository action secrets in API routes - Implement `ListActionsSecrets` function to retrieve action secrets from the database - Update Swagger documentation to include the new `/repos/{owner}/{repo}/actions/secrets` endpoint - Add `actions` package import and define new routes for actions, secrets, variables, and runners in `api.go`. - Refactor action-related API functions into `Action` struct methods in `org/action.go` and `repo/action.go`. - Remove `actionAPI` struct and related functions, replacing them with `NewAction()` calls. - Rename `variables.go` to `action.go` in `org` directory. - Delete `runners.go` and `secrets.go` in both `org` and `repo` directories, consolidating their content into `action.go`. - Update copyright year and add new imports in `org/action.go`. - Implement `API` interface in `services/actions/interface.go` for action-related methods. - Remove individual action-related functions and replace them with methods on the `Action` struct in `repo/action.go`. --------- Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com> Signed-off-by: appleboy <appleboy.tw@gmail.com>
* Interpolate runs-on with variables when scheduling tasks (#30640)sillyguodong2024-04-231-1/+7
| | | | | | | | | | Follow #29468 1. Interpolate runs-on with variables when scheduling tasks. 2. The `GetVariablesOfRun` function will check if the `Repo` of the run is nil. --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Enable more `revive` linter rules (#30608)silverwind2024-04-221-3/+5
| | | | | | | | | | | Noteable additions: - `redefines-builtin-id` forbid variable names that shadow go builtins - `empty-lines` remove unnecessary empty lines that `gofumpt` does not remove for some reason - `superfluous-else` eliminate more superfluous `else` branches Rules are also sorted alphabetically and I cleaned up various parts of `.golangci.yml`.
* Use action user as the trigger user of schedules (#30581)yp053272024-04-201-2/+7
| | | | | | | | | | | | | | | | | Follow https://github.com/go-gitea/gitea/pull/30357 When user push to default branch, the schedule trigger user will be the user. When disable then enable action units in settings, the schedule trigger user will be action user. When repo is a mirror, the schedule trigger user will be action user. ( before it will return error, fixed by #30357) As scheduled job is a cron, the trigger user should be action user from Gitea, not a real user. --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Add `interface{}` to `any` replacement to `make fmt`, exclude `*.pb.go` (#30461)silverwind2024-04-131-1/+1
| | | | | | | Since https://github.com/go-gitea/gitea/pull/25686, a few `interface{}` have sneaked into the codebase. Add this replacement to `make fmt` to prevent this from happening again. Ideally a linter would do this, but I haven't found any suitable.
* Add commit status summary table to reduce query from commit status table ↵Lunny Xiao2024-04-121-12/+8
| | | | | | | | | | | | (#30223) This PR adds a new table named commit status summary to reduce queries from the commit status table. After this change, commit status summary table will be used for the final result, commit status table will be for details. --------- Co-authored-by: Jason Song <i@wolfogre.com>
* Avoid user does not exist error when detecting schedule actions when the ↵yp053272024-04-111-6/+3
| | | | | | | | | | | | | | | | commit author is an external user (#30357) ![image](https://github.com/go-gitea/gitea/assets/18380374/ddf6ee84-2242-49b9-b066-bd8429ba4d76) When repo is a mirror, and commit author is an external user, then `GetUserByEmail` will return error. reproduce/test: - mirror Gitea to your instance - disable action and enable it again, this will trigger `DetectAndHandleSchedules` ps: also follow #24706, it only fixed normal runs, not scheduled runs.
* Fix missed doer (#30231)Lunny Xiao2024-04-081-5/+5
| | | | | Fix #29879 Co-authored-by: Giteabot <teabot@gitea.io>
* Remove scheduled action tasks if the repo is archived (#30224)Zettat1232024-04-012-2/+7
| | | Fix #30220
* Add API for `Variables` (#29520)sillyguodong2024-03-281-0/+100
| | | | | | | close #27801 --------- Co-authored-by: silverwind <me@silverwind.io>
* Use db.ListOptionsAll instead of db.ListOptions{ListAll: true} (#29995)Lunny Xiao2024-03-221-1/+1
|
* Fix bugs in rerunning jobs (#29955)Zettat1232024-03-222-0/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | Fix #28761 Fix #27884 Fix #28093 ## Changes ### Rerun all jobs When rerun all jobs, status of the jobs with `needs` will be set to `blocked` instead of `waiting`. Therefore, these jobs will not run until the required jobs are completed. ### Rerun a single job When a single job is rerun, its dependents should also be rerun, just like GitHub does (https://github.com/go-gitea/gitea/issues/28761#issuecomment-2008620820). In this case, only the specified job will be set to `waiting`, its dependents will be set to `blocked` to wait the job. ### Show warning if every job has `needs` If every job in a workflow has `needs`, all jobs will be blocked and no job can be run. So I add a warning message. <img src="https://github.com/go-gitea/gitea/assets/15528715/88f43511-2360-465d-be96-ee92b57ff67b" width="480px" />
* Cancel previous runs of the same PR automatically (#29961)Jason Song2024-03-212-7/+7
| | | | | | | | | | | Follow #25716. Also cancel previous runs for `pull_request_sync`. It's not a bug since it original PR said "if the event is push". The main change is https://github.com/go-gitea/gitea/pull/29961/files#diff-08adda3f8ae0360937f46abb1f4418603bd3518522baa356be11c6c7ac4abcc3. And also rename `CancelRunningJobs` to `CancelPreviousJobs` to make it more clear.
* Fix invalid link of the commit status when ref is tag (#29752)yp053272024-03-191-3/+13
| | | | | | | | | | Fix #29731 Caused by #24634 Also remove fixme. ps: we can not fix the existed runs, as wrong refs are all recorded in DB, and we can not know whether they are branch or tag: ![image](https://github.com/go-gitea/gitea/assets/18380374/cb7cf266-f73f-419a-be1a-4689fdd1952a)
* add skip ci support for pull request title (#29774)Denys Konovalov2024-03-141-3/+7
| | | | | Extends #28075 to support [skip ci] inside PR titles. Close #29265
* Make runs-on support variable expression (#29468)sillyguodong2024-03-081-1/+12
| | | | | | | | As title. Close issue: https://gitea.com/gitea/act_runner/issues/445 Follow: https://gitea.com/gitea/act/pulls/91 Move `getSecretsOfTask` and `getVariablesOfTask` under `models` because of circular dependency issues.
* Add ac claim for old docker/build-push-action@v3 / current buildx gha cache ↵ChristopherHX2024-03-052-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#29584) Also resolves a warning for current releases ``` | ##[group]GitHub Actions runtime token ACs | ##[warning]Cannot parse GitHub Actions Runtime Token ACs: "undefined" is not valid JSON | ##[endgroup] ====> | ##[group]GitHub Actions runtime token ACs | ##[endgroup] ``` \* this is an error in v3 References in the docker org: - https://github.com/docker/build-push-action/blob/831ca179d3cf91cf0c90ca465a408fa61e2129a2/src/main.ts#L24 - https://github.com/docker/actions-toolkit/blob/7d8b4dc6694df35a06fae786427672ce27a8c18d/src/github.ts#L61 No known official action of GitHub makes use of this claim. Current releases throw an error when configure to use actions cache ``` | ERROR: failed to solve: failed to configure gha cache exporter: invalid token without access controls | ##[error]buildx failed with: ERROR: failed to solve: failed to configure gha cache exporter: invalid token without access controls ```
* Add empty repo check in `DetectAndHandleSchedules` (#29606)yp053272024-03-051-0/+4
| | | ![image](https://github.com/go-gitea/gitea/assets/18380374/e6081301-bd3e-4cf6-ba4e-e574348dffb4)
* Fix workflow trigger event IssueChangeXXX bug (#29559)yp053272024-03-031-2/+14
| | | | | | Bugs from #29308 Follow #29467 partly fix #29558
* Fix workflow trigger event bugs (#29467)Zettat1232024-02-281-1/+7
| | | | | | 1. Fix incorrect `HookEventType` for issue-related events in `IssueChangeAssignee` 2. Add `case "types"` in the `switch` block in `matchPullRequestEvent` to avoid warning logs