2018-10-18 16:53:05 +05:30
|
|
|
// Copyright 2018 The Gitea Authors. All rights reserved.
|
2022-11-27 23:50:29 +05:30
|
|
|
// SPDX-License-Identifier: MIT
|
2016-12-30 22:14:54 +05:30
|
|
|
|
|
|
|
package notification
|
|
|
|
|
|
|
|
import (
|
2022-11-19 13:42:33 +05:30
|
|
|
"context"
|
|
|
|
|
2022-06-13 15:07:59 +05:30
|
|
|
issues_model "code.gitea.io/gitea/models/issues"
|
2022-03-30 14:12:47 +05:30
|
|
|
packages_model "code.gitea.io/gitea/models/packages"
|
2021-12-10 06:57:50 +05:30
|
|
|
repo_model "code.gitea.io/gitea/models/repo"
|
2021-11-24 15:19:20 +05:30
|
|
|
user_model "code.gitea.io/gitea/models/user"
|
2023-05-26 06:34:48 +05:30
|
|
|
"code.gitea.io/gitea/modules/git"
|
Implement actions (#21937)
Close #13539.
Co-authored by: @lunny @appleboy @fuxiaohei and others.
Related projects:
- https://gitea.com/gitea/actions-proto-def
- https://gitea.com/gitea/actions-proto-go
- https://gitea.com/gitea/act
- https://gitea.com/gitea/act_runner
### Summary
The target of this PR is to bring a basic implementation of "Actions",
an internal CI/CD system of Gitea. That means even though it has been
merged, the state of the feature is **EXPERIMENTAL**, and please note
that:
- It is disabled by default;
- It shouldn't be used in a production environment currently;
- It shouldn't be used in a public Gitea instance currently;
- Breaking changes may be made before it's stable.
**Please comment on #13539 if you have any different product design
ideas**, all decisions reached there will be adopted here. But in this
PR, we don't talk about **naming, feature-creep or alternatives**.
### ⚠️ Breaking
`gitea-actions` will become a reserved user name. If a user with the
name already exists in the database, it is recommended to rename it.
### Some important reviews
- What is `DEFAULT_ACTIONS_URL` in `app.ini` for?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1055954954
- Why the api for runners is not under the normal `/api/v1` prefix?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1061173592
- Why DBFS?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1061301178
- Why ignore events triggered by `gitea-actions` bot?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1063254103
- Why there's no permission control for actions?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1090229868
### What it looks like
<details>
#### Manage runners
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205870657-c72f590e-2e08-4cd4-be7f-2e0abb299bbf.png">
#### List runs
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205872794-50fde990-2b45-48c1-a178-908e4ec5b627.png">
#### View logs
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205872501-9b7b9000-9542-4991-8f55-18ccdada77c3.png">
</details>
### How to try it
<details>
#### 1. Start Gitea
Clone this branch and [install from
source](https://docs.gitea.io/en-us/install-from-source).
Add additional configurations in `app.ini` to enable Actions:
```ini
[actions]
ENABLED = true
```
Start it.
If all is well, you'll see the management page of runners:
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205877365-8e30a780-9b10-4154-b3e8-ee6c3cb35a59.png">
#### 2. Start runner
Clone the [act_runner](https://gitea.com/gitea/act_runner), and follow
the
[README](https://gitea.com/gitea/act_runner/src/branch/main/README.md)
to start it.
If all is well, you'll see a new runner has been added:
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205878000-216f5937-e696-470d-b66c-8473987d91c3.png">
#### 3. Enable actions for a repo
Create a new repo or open an existing one, check the `Actions` checkbox
in settings and submit.
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205879705-53e09208-73c0-4b3e-a123-2dcf9aba4b9c.png">
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205879383-23f3d08f-1a85-41dd-a8b3-54e2ee6453e8.png">
If all is well, you'll see a new tab "Actions":
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205881648-a8072d8c-5803-4d76-b8a8-9b2fb49516c1.png">
#### 4. Upload workflow files
Upload some workflow files to `.gitea/workflows/xxx.yaml`, you can
follow the [quickstart](https://docs.github.com/en/actions/quickstart)
of GitHub Actions. Yes, Gitea Actions is compatible with GitHub Actions
in most cases, you can use the same demo:
```yaml
name: GitHub Actions Demo
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
on: [push]
jobs:
Explore-GitHub-Actions:
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v3
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- run: echo "🍏 This job's status is ${{ job.status }}."
```
If all is well, you'll see a new run in `Actions` tab:
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205884473-79a874bc-171b-4aaf-acd5-0241a45c3b53.png">
#### 5. Check the logs of jobs
Click a run and you'll see the logs:
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205884800-994b0374-67f7-48ff-be9a-4c53f3141547.png">
#### 6. Go on
You can try more examples in [the
documents](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions)
of GitHub Actions, then you might find a lot of bugs.
Come on, PRs are welcome.
</details>
See also: [Feature Preview: Gitea
Actions](https://blog.gitea.io/2022/12/feature-preview-gitea-actions/)
---------
Co-authored-by: a1012112796 <1012112796@qq.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: ChristopherHX <christopher.homberger@web.de>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2023-01-31 07:15:19 +05:30
|
|
|
"code.gitea.io/gitea/modules/log"
|
2019-11-04 02:29:09 +05:30
|
|
|
"code.gitea.io/gitea/modules/notification/action"
|
2018-10-18 16:53:05 +05:30
|
|
|
"code.gitea.io/gitea/modules/notification/base"
|
2019-01-17 19:53:22 +05:30
|
|
|
"code.gitea.io/gitea/modules/notification/indexer"
|
2019-01-13 20:12:55 +05:30
|
|
|
"code.gitea.io/gitea/modules/notification/mail"
|
2018-10-18 16:53:05 +05:30
|
|
|
"code.gitea.io/gitea/modules/notification/ui"
|
2020-01-10 15:04:21 +05:30
|
|
|
"code.gitea.io/gitea/modules/repository"
|
2019-10-25 20:16:37 +05:30
|
|
|
"code.gitea.io/gitea/modules/setting"
|
2016-12-30 22:14:54 +05:30
|
|
|
)
|
|
|
|
|
2022-01-20 23:16:10 +05:30
|
|
|
var notifiers []base.Notifier
|
2018-10-18 16:53:05 +05:30
|
|
|
|
|
|
|
// RegisterNotifier providers method to receive notify messages
|
|
|
|
func RegisterNotifier(notifier base.Notifier) {
|
|
|
|
go notifier.Run()
|
|
|
|
notifiers = append(notifiers, notifier)
|
|
|
|
}
|
|
|
|
|
2019-10-25 20:16:37 +05:30
|
|
|
// NewContext registers notification handlers
|
|
|
|
func NewContext() {
|
2018-10-18 16:53:05 +05:30
|
|
|
RegisterNotifier(ui.NewNotifier())
|
2019-10-25 20:16:37 +05:30
|
|
|
if setting.Service.EnableNotifyMail {
|
|
|
|
RegisterNotifier(mail.NewNotifier())
|
|
|
|
}
|
2019-01-17 19:53:22 +05:30
|
|
|
RegisterNotifier(indexer.NewNotifier())
|
2019-11-04 02:29:09 +05:30
|
|
|
RegisterNotifier(action.NewNotifier())
|
2018-10-18 16:53:05 +05:30
|
|
|
}
|
|
|
|
|
2022-09-05 01:24:23 +05:30
|
|
|
// NotifyNewWikiPage notifies creating new wiki pages to notifiers
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyNewWikiPage(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, page, comment string) {
|
2022-09-05 01:24:23 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyNewWikiPage(ctx, doer, repo, page, comment)
|
2022-09-05 01:24:23 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyEditWikiPage notifies editing or renaming wiki pages to notifiers
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyEditWikiPage(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, page, comment string) {
|
2022-09-05 01:24:23 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyEditWikiPage(ctx, doer, repo, page, comment)
|
2022-09-05 01:24:23 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyDeleteWikiPage notifies deleting wiki pages to notifiers
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyDeleteWikiPage(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, page string) {
|
2022-09-05 01:24:23 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyDeleteWikiPage(ctx, doer, repo, page)
|
2022-09-05 01:24:23 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-18 16:53:05 +05:30
|
|
|
// NotifyCreateIssueComment notifies issue comment related message to notifiers
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyCreateIssueComment(ctx context.Context, doer *user_model.User, repo *repo_model.Repository,
|
2022-06-13 15:07:59 +05:30
|
|
|
issue *issues_model.Issue, comment *issues_model.Comment, mentions []*user_model.User,
|
2022-02-24 01:46:07 +05:30
|
|
|
) {
|
2018-10-18 16:53:05 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyCreateIssueComment(ctx, doer, repo, issue, comment, mentions)
|
2016-12-30 22:14:54 +05:30
|
|
|
}
|
2018-10-18 16:53:05 +05:30
|
|
|
}
|
2016-12-30 22:14:54 +05:30
|
|
|
|
2018-10-18 16:53:05 +05:30
|
|
|
// NotifyNewIssue notifies new issue to notifiers
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyNewIssue(ctx context.Context, issue *issues_model.Issue, mentions []*user_model.User) {
|
2018-10-18 16:53:05 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyNewIssue(ctx, issue, mentions)
|
2016-12-30 22:14:54 +05:30
|
|
|
}
|
2018-10-18 16:53:05 +05:30
|
|
|
}
|
2016-12-30 22:14:54 +05:30
|
|
|
|
2018-10-18 16:53:05 +05:30
|
|
|
// NotifyIssueChangeStatus notifies close or reopen issue to notifiers
|
2023-01-25 10:17:53 +05:30
|
|
|
func NotifyIssueChangeStatus(ctx context.Context, doer *user_model.User, commitID string, issue *issues_model.Issue, actionComment *issues_model.Comment, closeOrReopen bool) {
|
2018-10-18 16:53:05 +05:30
|
|
|
for _, notifier := range notifiers {
|
2023-01-25 10:17:53 +05:30
|
|
|
notifier.NotifyIssueChangeStatus(ctx, doer, commitID, issue, actionComment, closeOrReopen)
|
2016-12-30 22:14:54 +05:30
|
|
|
}
|
2018-10-18 16:53:05 +05:30
|
|
|
}
|
2016-12-30 22:14:54 +05:30
|
|
|
|
2022-03-01 05:50:15 +05:30
|
|
|
// NotifyDeleteIssue notify when some issue deleted
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyDeleteIssue(ctx context.Context, doer *user_model.User, issue *issues_model.Issue) {
|
2022-03-01 05:50:15 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyDeleteIssue(ctx, doer, issue)
|
2022-03-01 05:50:15 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-18 16:53:05 +05:30
|
|
|
// NotifyMergePullRequest notifies merge pull request to notifiers
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyMergePullRequest(ctx context.Context, doer *user_model.User, pr *issues_model.PullRequest) {
|
2018-10-18 16:53:05 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyMergePullRequest(ctx, doer, pr)
|
2018-10-18 16:53:05 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-03 21:19:00 +05:30
|
|
|
// NotifyAutoMergePullRequest notifies merge pull request to notifiers
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyAutoMergePullRequest(ctx context.Context, doer *user_model.User, pr *issues_model.PullRequest) {
|
2022-11-03 21:19:00 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyAutoMergePullRequest(ctx, doer, pr)
|
2022-11-03 21:19:00 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-18 16:53:05 +05:30
|
|
|
// NotifyNewPullRequest notifies new pull request to notifiers
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyNewPullRequest(ctx context.Context, pr *issues_model.PullRequest, mentions []*user_model.User) {
|
Implement actions (#21937)
Close #13539.
Co-authored by: @lunny @appleboy @fuxiaohei and others.
Related projects:
- https://gitea.com/gitea/actions-proto-def
- https://gitea.com/gitea/actions-proto-go
- https://gitea.com/gitea/act
- https://gitea.com/gitea/act_runner
### Summary
The target of this PR is to bring a basic implementation of "Actions",
an internal CI/CD system of Gitea. That means even though it has been
merged, the state of the feature is **EXPERIMENTAL**, and please note
that:
- It is disabled by default;
- It shouldn't be used in a production environment currently;
- It shouldn't be used in a public Gitea instance currently;
- Breaking changes may be made before it's stable.
**Please comment on #13539 if you have any different product design
ideas**, all decisions reached there will be adopted here. But in this
PR, we don't talk about **naming, feature-creep or alternatives**.
### ⚠️ Breaking
`gitea-actions` will become a reserved user name. If a user with the
name already exists in the database, it is recommended to rename it.
### Some important reviews
- What is `DEFAULT_ACTIONS_URL` in `app.ini` for?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1055954954
- Why the api for runners is not under the normal `/api/v1` prefix?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1061173592
- Why DBFS?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1061301178
- Why ignore events triggered by `gitea-actions` bot?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1063254103
- Why there's no permission control for actions?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1090229868
### What it looks like
<details>
#### Manage runners
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205870657-c72f590e-2e08-4cd4-be7f-2e0abb299bbf.png">
#### List runs
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205872794-50fde990-2b45-48c1-a178-908e4ec5b627.png">
#### View logs
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205872501-9b7b9000-9542-4991-8f55-18ccdada77c3.png">
</details>
### How to try it
<details>
#### 1. Start Gitea
Clone this branch and [install from
source](https://docs.gitea.io/en-us/install-from-source).
Add additional configurations in `app.ini` to enable Actions:
```ini
[actions]
ENABLED = true
```
Start it.
If all is well, you'll see the management page of runners:
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205877365-8e30a780-9b10-4154-b3e8-ee6c3cb35a59.png">
#### 2. Start runner
Clone the [act_runner](https://gitea.com/gitea/act_runner), and follow
the
[README](https://gitea.com/gitea/act_runner/src/branch/main/README.md)
to start it.
If all is well, you'll see a new runner has been added:
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205878000-216f5937-e696-470d-b66c-8473987d91c3.png">
#### 3. Enable actions for a repo
Create a new repo or open an existing one, check the `Actions` checkbox
in settings and submit.
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205879705-53e09208-73c0-4b3e-a123-2dcf9aba4b9c.png">
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205879383-23f3d08f-1a85-41dd-a8b3-54e2ee6453e8.png">
If all is well, you'll see a new tab "Actions":
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205881648-a8072d8c-5803-4d76-b8a8-9b2fb49516c1.png">
#### 4. Upload workflow files
Upload some workflow files to `.gitea/workflows/xxx.yaml`, you can
follow the [quickstart](https://docs.github.com/en/actions/quickstart)
of GitHub Actions. Yes, Gitea Actions is compatible with GitHub Actions
in most cases, you can use the same demo:
```yaml
name: GitHub Actions Demo
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
on: [push]
jobs:
Explore-GitHub-Actions:
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v3
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- run: echo "🍏 This job's status is ${{ job.status }}."
```
If all is well, you'll see a new run in `Actions` tab:
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205884473-79a874bc-171b-4aaf-acd5-0241a45c3b53.png">
#### 5. Check the logs of jobs
Click a run and you'll see the logs:
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205884800-994b0374-67f7-48ff-be9a-4c53f3141547.png">
#### 6. Go on
You can try more examples in [the
documents](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions)
of GitHub Actions, then you might find a lot of bugs.
Come on, PRs are welcome.
</details>
See also: [Feature Preview: Gitea
Actions](https://blog.gitea.io/2022/12/feature-preview-gitea-actions/)
---------
Co-authored-by: a1012112796 <1012112796@qq.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: ChristopherHX <christopher.homberger@web.de>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2023-01-31 07:15:19 +05:30
|
|
|
if err := pr.LoadIssue(ctx); err != nil {
|
|
|
|
log.Error("%v", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if err := pr.Issue.LoadPoster(ctx); err != nil {
|
|
|
|
return
|
|
|
|
}
|
2018-10-18 16:53:05 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyNewPullRequest(ctx, pr, mentions)
|
2018-10-18 16:53:05 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-05 16:34:08 +05:30
|
|
|
// NotifyPullRequestSynchronized notifies Synchronized pull request
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyPullRequestSynchronized(ctx context.Context, doer *user_model.User, pr *issues_model.PullRequest) {
|
2019-11-05 16:34:08 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyPullRequestSynchronized(ctx, doer, pr)
|
2019-11-05 16:34:08 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-18 16:53:05 +05:30
|
|
|
// NotifyPullRequestReview notifies new pull request review
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyPullRequestReview(ctx context.Context, pr *issues_model.PullRequest, review *issues_model.Review, comment *issues_model.Comment, mentions []*user_model.User) {
|
Implement actions (#21937)
Close #13539.
Co-authored by: @lunny @appleboy @fuxiaohei and others.
Related projects:
- https://gitea.com/gitea/actions-proto-def
- https://gitea.com/gitea/actions-proto-go
- https://gitea.com/gitea/act
- https://gitea.com/gitea/act_runner
### Summary
The target of this PR is to bring a basic implementation of "Actions",
an internal CI/CD system of Gitea. That means even though it has been
merged, the state of the feature is **EXPERIMENTAL**, and please note
that:
- It is disabled by default;
- It shouldn't be used in a production environment currently;
- It shouldn't be used in a public Gitea instance currently;
- Breaking changes may be made before it's stable.
**Please comment on #13539 if you have any different product design
ideas**, all decisions reached there will be adopted here. But in this
PR, we don't talk about **naming, feature-creep or alternatives**.
### ⚠️ Breaking
`gitea-actions` will become a reserved user name. If a user with the
name already exists in the database, it is recommended to rename it.
### Some important reviews
- What is `DEFAULT_ACTIONS_URL` in `app.ini` for?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1055954954
- Why the api for runners is not under the normal `/api/v1` prefix?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1061173592
- Why DBFS?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1061301178
- Why ignore events triggered by `gitea-actions` bot?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1063254103
- Why there's no permission control for actions?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1090229868
### What it looks like
<details>
#### Manage runners
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205870657-c72f590e-2e08-4cd4-be7f-2e0abb299bbf.png">
#### List runs
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205872794-50fde990-2b45-48c1-a178-908e4ec5b627.png">
#### View logs
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205872501-9b7b9000-9542-4991-8f55-18ccdada77c3.png">
</details>
### How to try it
<details>
#### 1. Start Gitea
Clone this branch and [install from
source](https://docs.gitea.io/en-us/install-from-source).
Add additional configurations in `app.ini` to enable Actions:
```ini
[actions]
ENABLED = true
```
Start it.
If all is well, you'll see the management page of runners:
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205877365-8e30a780-9b10-4154-b3e8-ee6c3cb35a59.png">
#### 2. Start runner
Clone the [act_runner](https://gitea.com/gitea/act_runner), and follow
the
[README](https://gitea.com/gitea/act_runner/src/branch/main/README.md)
to start it.
If all is well, you'll see a new runner has been added:
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205878000-216f5937-e696-470d-b66c-8473987d91c3.png">
#### 3. Enable actions for a repo
Create a new repo or open an existing one, check the `Actions` checkbox
in settings and submit.
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205879705-53e09208-73c0-4b3e-a123-2dcf9aba4b9c.png">
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205879383-23f3d08f-1a85-41dd-a8b3-54e2ee6453e8.png">
If all is well, you'll see a new tab "Actions":
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205881648-a8072d8c-5803-4d76-b8a8-9b2fb49516c1.png">
#### 4. Upload workflow files
Upload some workflow files to `.gitea/workflows/xxx.yaml`, you can
follow the [quickstart](https://docs.github.com/en/actions/quickstart)
of GitHub Actions. Yes, Gitea Actions is compatible with GitHub Actions
in most cases, you can use the same demo:
```yaml
name: GitHub Actions Demo
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
on: [push]
jobs:
Explore-GitHub-Actions:
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v3
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- run: echo "🍏 This job's status is ${{ job.status }}."
```
If all is well, you'll see a new run in `Actions` tab:
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205884473-79a874bc-171b-4aaf-acd5-0241a45c3b53.png">
#### 5. Check the logs of jobs
Click a run and you'll see the logs:
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205884800-994b0374-67f7-48ff-be9a-4c53f3141547.png">
#### 6. Go on
You can try more examples in [the
documents](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions)
of GitHub Actions, then you might find a lot of bugs.
Come on, PRs are welcome.
</details>
See also: [Feature Preview: Gitea
Actions](https://blog.gitea.io/2022/12/feature-preview-gitea-actions/)
---------
Co-authored-by: a1012112796 <1012112796@qq.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: ChristopherHX <christopher.homberger@web.de>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2023-01-31 07:15:19 +05:30
|
|
|
if err := review.LoadReviewer(ctx); err != nil {
|
|
|
|
log.Error("%v", err)
|
|
|
|
return
|
|
|
|
}
|
2018-10-18 16:53:05 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyPullRequestReview(ctx, pr, review, comment, mentions)
|
2021-01-02 22:34:02 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyPullRequestCodeComment notifies new pull request code comment
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyPullRequestCodeComment(ctx context.Context, pr *issues_model.PullRequest, comment *issues_model.Comment, mentions []*user_model.User) {
|
Implement actions (#21937)
Close #13539.
Co-authored by: @lunny @appleboy @fuxiaohei and others.
Related projects:
- https://gitea.com/gitea/actions-proto-def
- https://gitea.com/gitea/actions-proto-go
- https://gitea.com/gitea/act
- https://gitea.com/gitea/act_runner
### Summary
The target of this PR is to bring a basic implementation of "Actions",
an internal CI/CD system of Gitea. That means even though it has been
merged, the state of the feature is **EXPERIMENTAL**, and please note
that:
- It is disabled by default;
- It shouldn't be used in a production environment currently;
- It shouldn't be used in a public Gitea instance currently;
- Breaking changes may be made before it's stable.
**Please comment on #13539 if you have any different product design
ideas**, all decisions reached there will be adopted here. But in this
PR, we don't talk about **naming, feature-creep or alternatives**.
### ⚠️ Breaking
`gitea-actions` will become a reserved user name. If a user with the
name already exists in the database, it is recommended to rename it.
### Some important reviews
- What is `DEFAULT_ACTIONS_URL` in `app.ini` for?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1055954954
- Why the api for runners is not under the normal `/api/v1` prefix?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1061173592
- Why DBFS?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1061301178
- Why ignore events triggered by `gitea-actions` bot?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1063254103
- Why there's no permission control for actions?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1090229868
### What it looks like
<details>
#### Manage runners
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205870657-c72f590e-2e08-4cd4-be7f-2e0abb299bbf.png">
#### List runs
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205872794-50fde990-2b45-48c1-a178-908e4ec5b627.png">
#### View logs
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205872501-9b7b9000-9542-4991-8f55-18ccdada77c3.png">
</details>
### How to try it
<details>
#### 1. Start Gitea
Clone this branch and [install from
source](https://docs.gitea.io/en-us/install-from-source).
Add additional configurations in `app.ini` to enable Actions:
```ini
[actions]
ENABLED = true
```
Start it.
If all is well, you'll see the management page of runners:
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205877365-8e30a780-9b10-4154-b3e8-ee6c3cb35a59.png">
#### 2. Start runner
Clone the [act_runner](https://gitea.com/gitea/act_runner), and follow
the
[README](https://gitea.com/gitea/act_runner/src/branch/main/README.md)
to start it.
If all is well, you'll see a new runner has been added:
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205878000-216f5937-e696-470d-b66c-8473987d91c3.png">
#### 3. Enable actions for a repo
Create a new repo or open an existing one, check the `Actions` checkbox
in settings and submit.
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205879705-53e09208-73c0-4b3e-a123-2dcf9aba4b9c.png">
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205879383-23f3d08f-1a85-41dd-a8b3-54e2ee6453e8.png">
If all is well, you'll see a new tab "Actions":
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205881648-a8072d8c-5803-4d76-b8a8-9b2fb49516c1.png">
#### 4. Upload workflow files
Upload some workflow files to `.gitea/workflows/xxx.yaml`, you can
follow the [quickstart](https://docs.github.com/en/actions/quickstart)
of GitHub Actions. Yes, Gitea Actions is compatible with GitHub Actions
in most cases, you can use the same demo:
```yaml
name: GitHub Actions Demo
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
on: [push]
jobs:
Explore-GitHub-Actions:
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v3
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- run: echo "🍏 This job's status is ${{ job.status }}."
```
If all is well, you'll see a new run in `Actions` tab:
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205884473-79a874bc-171b-4aaf-acd5-0241a45c3b53.png">
#### 5. Check the logs of jobs
Click a run and you'll see the logs:
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205884800-994b0374-67f7-48ff-be9a-4c53f3141547.png">
#### 6. Go on
You can try more examples in [the
documents](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions)
of GitHub Actions, then you might find a lot of bugs.
Come on, PRs are welcome.
</details>
See also: [Feature Preview: Gitea
Actions](https://blog.gitea.io/2022/12/feature-preview-gitea-actions/)
---------
Co-authored-by: a1012112796 <1012112796@qq.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: ChristopherHX <christopher.homberger@web.de>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2023-01-31 07:15:19 +05:30
|
|
|
if err := comment.LoadPoster(ctx); err != nil {
|
|
|
|
log.Error("LoadPoster: %v", err)
|
|
|
|
return
|
|
|
|
}
|
2021-01-02 22:34:02 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyPullRequestCodeComment(ctx, pr, comment, mentions)
|
2018-10-18 16:53:05 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-16 11:50:25 +05:30
|
|
|
// NotifyPullRequestChangeTargetBranch notifies when a pull request's target branch was changed
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyPullRequestChangeTargetBranch(ctx context.Context, doer *user_model.User, pr *issues_model.PullRequest, oldBranch string) {
|
2019-12-16 11:50:25 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyPullRequestChangeTargetBranch(ctx, doer, pr, oldBranch)
|
2019-12-16 11:50:25 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-20 18:17:24 +05:30
|
|
|
// NotifyPullRequestPushCommits notifies when push commits to pull request's head branch
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyPullRequestPushCommits(ctx context.Context, doer *user_model.User, pr *issues_model.PullRequest, comment *issues_model.Comment) {
|
2020-05-20 18:17:24 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyPullRequestPushCommits(ctx, doer, pr, comment)
|
2020-05-20 18:17:24 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-19 13:42:33 +05:30
|
|
|
// NotifyPullReviewDismiss notifies when a review was dismissed by repo admin
|
|
|
|
func NotifyPullReviewDismiss(ctx context.Context, doer *user_model.User, review *issues_model.Review, comment *issues_model.Comment) {
|
2021-02-11 23:02:25 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyPullReviewDismiss(ctx, doer, review, comment)
|
2021-02-11 23:02:25 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-18 16:53:05 +05:30
|
|
|
// NotifyUpdateComment notifies update comment to notifiers
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyUpdateComment(ctx context.Context, doer *user_model.User, c *issues_model.Comment, oldContent string) {
|
2018-10-18 16:53:05 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyUpdateComment(ctx, doer, c, oldContent)
|
2018-10-18 16:53:05 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyDeleteComment notifies delete comment to notifiers
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyDeleteComment(ctx context.Context, doer *user_model.User, c *issues_model.Comment) {
|
2018-10-18 16:53:05 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyDeleteComment(ctx, doer, c)
|
2018-10-18 16:53:05 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyNewRelease notifies new release to notifiers
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyNewRelease(ctx context.Context, rel *repo_model.Release) {
|
Implement actions (#21937)
Close #13539.
Co-authored by: @lunny @appleboy @fuxiaohei and others.
Related projects:
- https://gitea.com/gitea/actions-proto-def
- https://gitea.com/gitea/actions-proto-go
- https://gitea.com/gitea/act
- https://gitea.com/gitea/act_runner
### Summary
The target of this PR is to bring a basic implementation of "Actions",
an internal CI/CD system of Gitea. That means even though it has been
merged, the state of the feature is **EXPERIMENTAL**, and please note
that:
- It is disabled by default;
- It shouldn't be used in a production environment currently;
- It shouldn't be used in a public Gitea instance currently;
- Breaking changes may be made before it's stable.
**Please comment on #13539 if you have any different product design
ideas**, all decisions reached there will be adopted here. But in this
PR, we don't talk about **naming, feature-creep or alternatives**.
### ⚠️ Breaking
`gitea-actions` will become a reserved user name. If a user with the
name already exists in the database, it is recommended to rename it.
### Some important reviews
- What is `DEFAULT_ACTIONS_URL` in `app.ini` for?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1055954954
- Why the api for runners is not under the normal `/api/v1` prefix?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1061173592
- Why DBFS?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1061301178
- Why ignore events triggered by `gitea-actions` bot?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1063254103
- Why there's no permission control for actions?
- https://github.com/go-gitea/gitea/pull/21937#discussion_r1090229868
### What it looks like
<details>
#### Manage runners
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205870657-c72f590e-2e08-4cd4-be7f-2e0abb299bbf.png">
#### List runs
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205872794-50fde990-2b45-48c1-a178-908e4ec5b627.png">
#### View logs
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205872501-9b7b9000-9542-4991-8f55-18ccdada77c3.png">
</details>
### How to try it
<details>
#### 1. Start Gitea
Clone this branch and [install from
source](https://docs.gitea.io/en-us/install-from-source).
Add additional configurations in `app.ini` to enable Actions:
```ini
[actions]
ENABLED = true
```
Start it.
If all is well, you'll see the management page of runners:
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205877365-8e30a780-9b10-4154-b3e8-ee6c3cb35a59.png">
#### 2. Start runner
Clone the [act_runner](https://gitea.com/gitea/act_runner), and follow
the
[README](https://gitea.com/gitea/act_runner/src/branch/main/README.md)
to start it.
If all is well, you'll see a new runner has been added:
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205878000-216f5937-e696-470d-b66c-8473987d91c3.png">
#### 3. Enable actions for a repo
Create a new repo or open an existing one, check the `Actions` checkbox
in settings and submit.
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205879705-53e09208-73c0-4b3e-a123-2dcf9aba4b9c.png">
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205879383-23f3d08f-1a85-41dd-a8b3-54e2ee6453e8.png">
If all is well, you'll see a new tab "Actions":
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205881648-a8072d8c-5803-4d76-b8a8-9b2fb49516c1.png">
#### 4. Upload workflow files
Upload some workflow files to `.gitea/workflows/xxx.yaml`, you can
follow the [quickstart](https://docs.github.com/en/actions/quickstart)
of GitHub Actions. Yes, Gitea Actions is compatible with GitHub Actions
in most cases, you can use the same demo:
```yaml
name: GitHub Actions Demo
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
on: [push]
jobs:
Explore-GitHub-Actions:
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v3
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- run: echo "🍏 This job's status is ${{ job.status }}."
```
If all is well, you'll see a new run in `Actions` tab:
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205884473-79a874bc-171b-4aaf-acd5-0241a45c3b53.png">
#### 5. Check the logs of jobs
Click a run and you'll see the logs:
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205884800-994b0374-67f7-48ff-be9a-4c53f3141547.png">
#### 6. Go on
You can try more examples in [the
documents](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions)
of GitHub Actions, then you might find a lot of bugs.
Come on, PRs are welcome.
</details>
See also: [Feature Preview: Gitea
Actions](https://blog.gitea.io/2022/12/feature-preview-gitea-actions/)
---------
Co-authored-by: a1012112796 <1012112796@qq.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: ChristopherHX <christopher.homberger@web.de>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2023-01-31 07:15:19 +05:30
|
|
|
if err := rel.LoadAttributes(ctx); err != nil {
|
|
|
|
log.Error("LoadPublisher: %v", err)
|
|
|
|
return
|
|
|
|
}
|
2018-10-18 16:53:05 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyNewRelease(ctx, rel)
|
2018-10-18 16:53:05 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyUpdateRelease notifies update release to notifiers
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyUpdateRelease(ctx context.Context, doer *user_model.User, rel *repo_model.Release) {
|
2018-10-18 16:53:05 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyUpdateRelease(ctx, doer, rel)
|
2018-10-18 16:53:05 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyDeleteRelease notifies delete release to notifiers
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyDeleteRelease(ctx context.Context, doer *user_model.User, rel *repo_model.Release) {
|
2018-10-18 16:53:05 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyDeleteRelease(ctx, doer, rel)
|
2018-10-18 16:53:05 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyIssueChangeMilestone notifies change milestone to notifiers
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyIssueChangeMilestone(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, oldMilestoneID int64) {
|
2018-10-18 16:53:05 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyIssueChangeMilestone(ctx, doer, issue, oldMilestoneID)
|
2018-10-18 16:53:05 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyIssueChangeContent notifies change content to notifiers
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyIssueChangeContent(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, oldContent string) {
|
2018-10-18 16:53:05 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyIssueChangeContent(ctx, doer, issue, oldContent)
|
2018-10-18 16:53:05 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyIssueChangeAssignee notifies change content to notifiers
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyIssueChangeAssignee(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, assignee *user_model.User, removed bool, comment *issues_model.Comment) {
|
2018-10-18 16:53:05 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyIssueChangeAssignee(ctx, doer, issue, assignee, removed, comment)
|
2018-10-18 16:53:05 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-31 13:24:46 +05:30
|
|
|
// NotifyPullRequestReviewRequest notifies Request Review change
|
|
|
|
func NotifyPullRequestReviewRequest(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, reviewer *user_model.User, isRequest bool, comment *issues_model.Comment) {
|
2020-04-06 22:03:34 +05:30
|
|
|
for _, notifier := range notifiers {
|
2023-05-31 13:24:46 +05:30
|
|
|
notifier.NotifyPullRequestReviewRequest(ctx, doer, issue, reviewer, isRequest, comment)
|
2020-04-06 22:03:34 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-18 16:53:05 +05:30
|
|
|
// NotifyIssueClearLabels notifies clear labels to notifiers
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyIssueClearLabels(ctx context.Context, doer *user_model.User, issue *issues_model.Issue) {
|
2018-10-18 16:53:05 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyIssueClearLabels(ctx, doer, issue)
|
2018-10-18 16:53:05 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyIssueChangeTitle notifies change title to notifiers
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyIssueChangeTitle(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, oldTitle string) {
|
2018-10-18 16:53:05 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyIssueChangeTitle(ctx, doer, issue, oldTitle)
|
2018-10-18 16:53:05 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-08 21:59:51 +05:30
|
|
|
// NotifyIssueChangeRef notifies change reference to notifiers
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyIssueChangeRef(ctx context.Context, doer *user_model.User, issue *issues_model.Issue, oldRef string) {
|
2020-09-08 21:59:51 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyIssueChangeRef(ctx, doer, issue, oldRef)
|
2020-09-08 21:59:51 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-18 16:53:05 +05:30
|
|
|
// NotifyIssueChangeLabels notifies change labels to notifiers
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyIssueChangeLabels(ctx context.Context, doer *user_model.User, issue *issues_model.Issue,
|
2022-06-13 15:07:59 +05:30
|
|
|
addedLabels, removedLabels []*issues_model.Label,
|
2022-02-24 01:46:07 +05:30
|
|
|
) {
|
2018-10-18 16:53:05 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyIssueChangeLabels(ctx, doer, issue, addedLabels, removedLabels)
|
2018-10-18 16:53:05 +05:30
|
|
|
}
|
2016-12-30 22:14:54 +05:30
|
|
|
}
|
|
|
|
|
2018-10-18 16:53:05 +05:30
|
|
|
// NotifyCreateRepository notifies create repository to notifiers
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyCreateRepository(ctx context.Context, doer, u *user_model.User, repo *repo_model.Repository) {
|
2018-10-18 16:53:05 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyCreateRepository(ctx, doer, u, repo)
|
2016-12-30 22:14:54 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-26 12:29:15 +05:30
|
|
|
// NotifyAdoptRepository notifies the adoption of a repository to notifiers
|
|
|
|
func NotifyAdoptRepository(ctx context.Context, doer, u *user_model.User, repo *repo_model.Repository) {
|
|
|
|
for _, notifier := range notifiers {
|
|
|
|
notifier.NotifyAdoptRepository(ctx, doer, u, repo)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-18 16:53:05 +05:30
|
|
|
// NotifyMigrateRepository notifies create repository to notifiers
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyMigrateRepository(ctx context.Context, doer, u *user_model.User, repo *repo_model.Repository) {
|
2018-10-18 16:53:05 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyMigrateRepository(ctx, doer, u, repo)
|
2016-12-30 22:14:54 +05:30
|
|
|
}
|
|
|
|
}
|
2019-11-03 12:29:26 +05:30
|
|
|
|
2019-11-15 13:36:11 +05:30
|
|
|
// NotifyTransferRepository notifies create repository to notifiers
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyTransferRepository(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, newOwnerName string) {
|
2019-11-15 13:36:11 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyTransferRepository(ctx, doer, repo, newOwnerName)
|
2019-11-15 13:36:11 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyDeleteRepository notifies delete repository to notifiers
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyDeleteRepository(ctx context.Context, doer *user_model.User, repo *repo_model.Repository) {
|
2019-11-15 13:36:11 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyDeleteRepository(ctx, doer, repo)
|
2019-11-15 13:36:11 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyForkRepository notifies fork repository to notifiers
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyForkRepository(ctx context.Context, doer *user_model.User, oldRepo, repo *repo_model.Repository) {
|
2019-11-15 13:36:11 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyForkRepository(ctx, doer, oldRepo, repo)
|
2019-11-15 13:36:11 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyRenameRepository notifies repository renamed
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyRenameRepository(ctx context.Context, doer *user_model.User, repo *repo_model.Repository, oldName string) {
|
2019-11-15 13:36:11 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyRenameRepository(ctx, doer, repo, oldName)
|
2019-11-15 13:36:11 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-03 12:29:26 +05:30
|
|
|
// NotifyPushCommits notifies commits pushed to notifiers
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyPushCommits(ctx context.Context, pusher *user_model.User, repo *repo_model.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) {
|
2019-11-03 12:29:26 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyPushCommits(ctx, pusher, repo, opts, commits)
|
2019-11-03 12:29:26 +05:30
|
|
|
}
|
|
|
|
}
|
2019-11-06 12:13:03 +05:30
|
|
|
|
|
|
|
// NotifyCreateRef notifies branch or tag creation to notifiers
|
2023-05-26 06:34:48 +05:30
|
|
|
func NotifyCreateRef(ctx context.Context, pusher *user_model.User, repo *repo_model.Repository, refFullName git.RefName, refID string) {
|
2019-11-06 12:13:03 +05:30
|
|
|
for _, notifier := range notifiers {
|
2023-05-26 06:34:48 +05:30
|
|
|
notifier.NotifyCreateRef(ctx, pusher, repo, refFullName, refID)
|
2019-11-06 12:13:03 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyDeleteRef notifies branch or tag deletion to notifiers
|
2023-05-26 06:34:48 +05:30
|
|
|
func NotifyDeleteRef(ctx context.Context, pusher *user_model.User, repo *repo_model.Repository, refFullName git.RefName) {
|
2019-11-06 12:13:03 +05:30
|
|
|
for _, notifier := range notifiers {
|
2023-05-26 06:34:48 +05:30
|
|
|
notifier.NotifyDeleteRef(ctx, pusher, repo, refFullName)
|
2019-11-06 12:13:03 +05:30
|
|
|
}
|
|
|
|
}
|
2019-11-24 10:46:59 +05:30
|
|
|
|
|
|
|
// NotifySyncPushCommits notifies commits pushed to notifiers
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifySyncPushCommits(ctx context.Context, pusher *user_model.User, repo *repo_model.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) {
|
2019-11-24 10:46:59 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifySyncPushCommits(ctx, pusher, repo, opts, commits)
|
2019-11-24 10:46:59 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifySyncCreateRef notifies branch or tag creation to notifiers
|
2023-05-26 06:34:48 +05:30
|
|
|
func NotifySyncCreateRef(ctx context.Context, pusher *user_model.User, repo *repo_model.Repository, refFullName git.RefName, refID string) {
|
2019-11-24 10:46:59 +05:30
|
|
|
for _, notifier := range notifiers {
|
2023-05-26 06:34:48 +05:30
|
|
|
notifier.NotifySyncCreateRef(ctx, pusher, repo, refFullName, refID)
|
2019-11-24 10:46:59 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifySyncDeleteRef notifies branch or tag deletion to notifiers
|
2023-05-26 06:34:48 +05:30
|
|
|
func NotifySyncDeleteRef(ctx context.Context, pusher *user_model.User, repo *repo_model.Repository, refFullName git.RefName) {
|
2019-11-24 10:46:59 +05:30
|
|
|
for _, notifier := range notifiers {
|
2023-05-26 06:34:48 +05:30
|
|
|
notifier.NotifySyncDeleteRef(ctx, pusher, repo, refFullName)
|
2019-11-24 10:46:59 +05:30
|
|
|
}
|
|
|
|
}
|
2021-03-01 06:17:30 +05:30
|
|
|
|
|
|
|
// NotifyRepoPendingTransfer notifies creation of pending transfer to notifiers
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyRepoPendingTransfer(ctx context.Context, doer, newOwner *user_model.User, repo *repo_model.Repository) {
|
2021-03-01 06:17:30 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyRepoPendingTransfer(ctx, doer, newOwner, repo)
|
2021-03-01 06:17:30 +05:30
|
|
|
}
|
|
|
|
}
|
2022-03-30 14:12:47 +05:30
|
|
|
|
|
|
|
// NotifyPackageCreate notifies creation of a package to notifiers
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyPackageCreate(ctx context.Context, doer *user_model.User, pd *packages_model.PackageDescriptor) {
|
2022-03-30 14:12:47 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyPackageCreate(ctx, doer, pd)
|
2022-03-30 14:12:47 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NotifyPackageDelete notifies deletion of a package to notifiers
|
2022-11-19 13:42:33 +05:30
|
|
|
func NotifyPackageDelete(ctx context.Context, doer *user_model.User, pd *packages_model.PackageDescriptor) {
|
2022-03-30 14:12:47 +05:30
|
|
|
for _, notifier := range notifiers {
|
2022-11-19 13:42:33 +05:30
|
|
|
notifier.NotifyPackageDelete(ctx, doer, pd)
|
2022-03-30 14:12:47 +05:30
|
|
|
}
|
|
|
|
}
|