2016-02-15 08:26:47 +09:00
|
|
|
<div class="header-wrapper">
|
2014-10-19 14:35:24 +09:00
|
|
|
{{with .Repository}}
|
2017-12-31 09:47:52 +09:00
|
|
|
<div class="ui container">
|
2019-02-06 06:59:26 +09:00
|
|
|
<div class="repo-header">
|
2024-01-12 12:44:06 +09:00
|
|
|
<div class="flex-item gt-ac">
|
|
|
|
<div class="flex-item-leading">{{template "repo/icon" .}}</div>
|
|
|
|
<div class="flex-item-main">
|
2024-02-16 01:52:21 +09:00
|
|
|
<div class="flex-item-title gt-font-18">
|
|
|
|
<a class="muted gt-font-normal" href="{{.Owner.HomeLink}}">{{.Owner.Name}}</a>/
|
|
|
|
<a class="muted" href="{{$.RepoLink}}">{{.Name}}</a></div>
|
2024-01-12 12:44:06 +09:00
|
|
|
</div>
|
|
|
|
<div class="flex-item-trailing">
|
|
|
|
{{if .IsArchived}}
|
|
|
|
<span class="ui basic label">{{ctx.Locale.Tr "repo.desc.archived"}}</span>
|
|
|
|
<div class="repo-icon" data-tooltip-content="{{ctx.Locale.Tr "repo.desc.archived"}}">{{svg "octicon-archive" 18}}</div>
|
|
|
|
{{end}}
|
|
|
|
{{if .IsPrivate}}
|
|
|
|
<span class="ui basic label">{{ctx.Locale.Tr "repo.desc.private"}}</span>
|
|
|
|
<div class="repo-icon" data-tooltip-content="{{ctx.Locale.Tr "repo.desc.private"}}">{{svg "octicon-lock" 18}}</div>
|
|
|
|
{{else}}
|
|
|
|
{{if .Owner.Visibility.IsPrivate}}
|
|
|
|
<span class="ui basic label">{{ctx.Locale.Tr "repo.desc.internal"}}</span>
|
|
|
|
<div class="repo-icon" data-tooltip-content="{{ctx.Locale.Tr "repo.desc.internal"}}">{{svg "octicon-shield-lock" 18}}</div>
|
2020-12-08 13:14:28 +09:00
|
|
|
{{end}}
|
2024-01-12 12:44:06 +09:00
|
|
|
{{end}}
|
|
|
|
{{if .IsTemplate}}
|
|
|
|
<span class="ui basic label">{{ctx.Locale.Tr "repo.desc.template"}}</span>
|
|
|
|
<div class="repo-icon" data-tooltip-content="{{ctx.Locale.Tr "repo.desc.template"}}">{{svg "octicon-repo-template" 18}}</div>
|
|
|
|
{{end}}
|
2024-01-20 01:05:02 +09:00
|
|
|
{{if eq .ObjectFormatName "sha256"}}
|
|
|
|
<span class="ui basic label">{{ctx.Locale.Tr "repo.desc.sha256"}}</span>
|
|
|
|
{{end}}
|
2020-12-08 13:14:28 +09:00
|
|
|
</div>
|
2017-12-31 09:47:52 +09:00
|
|
|
</div>
|
2021-11-23 07:32:16 +09:00
|
|
|
{{if not (or .IsBeingCreated .IsBroken)}}
|
2019-10-13 22:23:14 +09:00
|
|
|
<div class="repo-buttons">
|
2021-03-01 09:47:30 +09:00
|
|
|
{{if $.RepoTransfer}}
|
|
|
|
<form method="post" action="{{$.RepoLink}}/action/accept_transfer?redirect_to={{$.RepoLink}}">
|
|
|
|
{{$.CsrfTokenHtml}}
|
2023-09-25 17:56:50 +09:00
|
|
|
<div data-tooltip-content="{{if $.CanUserAcceptTransfer}}{{ctx.Locale.Tr "repo.transfer.accept_desc" $.RepoTransfer.Recipient.DisplayName}}{{else}}{{ctx.Locale.Tr "repo.transfer.no_permission_to_accept"}}{{end}}">
|
2023-09-19 07:05:31 +09:00
|
|
|
<button type="submit" class="ui basic button {{if $.CanUserAcceptTransfer}}primary {{end}} ok small"{{if not $.CanUserAcceptTransfer}} disabled{{end}}>
|
2023-09-25 17:56:50 +09:00
|
|
|
{{ctx.Locale.Tr "repo.transfer.accept"}}
|
2021-03-01 09:47:30 +09:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
<form method="post" action="{{$.RepoLink}}/action/reject_transfer?redirect_to={{$.RepoLink}}">
|
|
|
|
{{$.CsrfTokenHtml}}
|
2023-09-25 17:56:50 +09:00
|
|
|
<div data-tooltip-content="{{if $.CanUserAcceptTransfer}}{{ctx.Locale.Tr "repo.transfer.reject_desc" $.RepoTransfer.Recipient.DisplayName}}{{else}}{{ctx.Locale.Tr "repo.transfer.no_permission_to_reject"}}{{end}}">
|
2023-05-04 22:21:30 +09:00
|
|
|
<button type="submit" class="ui basic button {{if $.CanUserAcceptTransfer}}red {{end}}ok small"{{if not $.CanUserAcceptTransfer}} disabled{{end}}>
|
2023-09-25 17:56:50 +09:00
|
|
|
{{ctx.Locale.Tr "repo.transfer.reject"}}
|
2021-03-01 09:47:30 +09:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
{{end}}
|
2023-12-07 05:29:26 +09:00
|
|
|
{{if $.EnableFeed}}
|
|
|
|
{{/* An extra div-element is not necessary here, as this button does not secretly contain two buttons. */}}
|
2023-12-07 12:01:32 +09:00
|
|
|
<a class="ui compact small basic button" href="{{$.RepoLink}}.rss" data-tooltip-content="{{ctx.Locale.Tr "rss_feed"}}">
|
2023-12-07 05:29:26 +09:00
|
|
|
{{svg "octicon-rss" 16}}
|
2023-12-07 12:01:32 +09:00
|
|
|
</a>
|
2023-12-07 05:29:26 +09:00
|
|
|
{{end}}
|
2024-02-05 18:56:20 +09:00
|
|
|
{{template "repo/watch_unwatch" $}}
|
2021-04-16 01:53:57 +09:00
|
|
|
{{if not $.DisableStars}}
|
2024-02-05 18:56:20 +09:00
|
|
|
{{template "repo/star_unstar" $}}
|
2021-04-16 01:53:57 +09:00
|
|
|
{{end}}
|
2024-02-25 19:58:23 +09:00
|
|
|
{{if not $.DisableForks}}
|
|
|
|
{{template "repo/header_fork" $}}
|
2019-10-13 22:23:14 +09:00
|
|
|
{{end}}
|
|
|
|
</div>
|
|
|
|
{{end}}
|
2024-01-12 12:44:06 +09:00
|
|
|
</div>
|
2024-01-18 19:27:07 +09:00
|
|
|
{{if $.PullMirror}}
|
|
|
|
<div class="fork-flag">
|
|
|
|
{{ctx.Locale.Tr "repo.mirror_from"}}
|
|
|
|
<a target="_blank" rel="noopener noreferrer" href="{{$.PullMirror.RemoteAddress}}">{{$.PullMirror.RemoteAddress}}</a>
|
|
|
|
{{if $.PullMirror.UpdatedUnix}}{{ctx.Locale.Tr "repo.mirror_sync"}} {{TimeSinceUnix $.PullMirror.UpdatedUnix ctx.Locale}}{{end}}
|
|
|
|
</div>
|
|
|
|
{{end}}
|
2024-01-12 12:44:06 +09:00
|
|
|
{{if .IsFork}}<div class="fork-flag">{{ctx.Locale.Tr "repo.forked_from"}} <a href="{{.BaseRepo.Link}}">{{.BaseRepo.FullName}}</a></div>{{end}}
|
|
|
|
{{if .IsGenerated}}<div class="fork-flag">{{ctx.Locale.Tr "repo.generated_from"}} <a href="{{(.TemplateRepo ctx).Link}}">{{(.TemplateRepo ctx).FullName}}</a></div>{{end}}
|
|
|
|
</div>
|
2015-08-12 19:12:06 +09:00
|
|
|
{{end}}
|
2024-03-15 11:05:31 +09:00
|
|
|
<overflow-menu class="ui container secondary pointing tabular top attached borderless menu navbar tw-pt-0 tw-my-0">
|
2021-11-23 07:32:16 +09:00
|
|
|
{{if not (or .Repository.IsBeingCreated .Repository.IsBroken)}}
|
2024-03-15 11:05:31 +09:00
|
|
|
<div class="overflow-menu-items">
|
2019-10-13 22:23:14 +09:00
|
|
|
{{if .Permission.CanRead $.UnitTypeCode}}
|
2023-11-27 14:59:56 +09:00
|
|
|
<a class="{{if .PageIsViewCode}}active {{end}}item" href="{{.RepoLink}}{{if and (ne .BranchName .Repository.DefaultBranch) (not $.PageIsWiki)}}/src/{{.BranchNameSubURL}}{{end}}">
|
2023-09-25 17:56:50 +09:00
|
|
|
{{svg "octicon-code"}} {{ctx.Locale.Tr "repo.code"}}
|
2017-02-05 00:53:46 +09:00
|
|
|
</a>
|
2019-10-13 22:23:14 +09:00
|
|
|
{{end}}
|
2017-03-18 19:59:07 +09:00
|
|
|
|
2019-10-13 22:23:14 +09:00
|
|
|
{{if .Permission.CanRead $.UnitTypeIssues}}
|
2022-12-09 22:34:51 +09:00
|
|
|
<a class="{{if .PageIsIssueList}}active {{end}}item" href="{{.RepoLink}}/issues">
|
2023-09-25 17:56:50 +09:00
|
|
|
{{svg "octicon-issue-opened"}} {{ctx.Locale.Tr "repo.issues"}}
|
2020-10-24 20:54:33 +09:00
|
|
|
{{if .Repository.NumOpenIssues}}
|
2023-02-04 07:25:55 +09:00
|
|
|
<span class="ui small label">{{CountFmt .Repository.NumOpenIssues}}</span>
|
2020-10-24 20:54:33 +09:00
|
|
|
{{end}}
|
2019-10-13 22:23:14 +09:00
|
|
|
</a>
|
|
|
|
{{end}}
|
2017-02-05 00:53:46 +09:00
|
|
|
|
2019-10-13 22:23:14 +09:00
|
|
|
{{if .Permission.CanRead $.UnitTypeExternalTracker}}
|
2022-12-09 22:34:51 +09:00
|
|
|
<a class="{{if .PageIsIssueList}}active {{end}}item" href="{{.RepoExternalIssuesLink}}" target="_blank" rel="noopener noreferrer">
|
2023-09-25 17:56:50 +09:00
|
|
|
{{svg "octicon-link-external"}} {{ctx.Locale.Tr "repo.issues"}}
|
2019-10-13 22:23:14 +09:00
|
|
|
</a>
|
|
|
|
{{end}}
|
2017-02-05 00:53:46 +09:00
|
|
|
|
2019-10-13 22:23:14 +09:00
|
|
|
{{if and .Repository.CanEnablePulls (.Permission.CanRead $.UnitTypePullRequests)}}
|
2022-12-09 22:34:51 +09:00
|
|
|
<a class="{{if .PageIsPullList}}active {{end}}item" href="{{.RepoLink}}/pulls">
|
2023-09-25 17:56:50 +09:00
|
|
|
{{svg "octicon-git-pull-request"}} {{ctx.Locale.Tr "repo.pulls"}}
|
2020-10-24 20:54:33 +09:00
|
|
|
{{if .Repository.NumOpenPulls}}
|
2023-02-04 07:25:55 +09:00
|
|
|
<span class="ui small label">{{CountFmt .Repository.NumOpenPulls}}</span>
|
2020-10-24 20:54:33 +09:00
|
|
|
{{end}}
|
2019-10-13 22:23:14 +09:00
|
|
|
</a>
|
|
|
|
{{end}}
|
2017-02-05 00:53:46 +09:00
|
|
|
|
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 10:45:19 +09:00
|
|
|
{{if and .EnableActions (not .UnitActionsGlobalDisabled) (.Permission.CanRead $.UnitTypeActions)}}
|
|
|
|
<a class="{{if .PageIsActions}}active {{end}}item" href="{{.RepoLink}}/actions">
|
2023-09-25 17:56:50 +09:00
|
|
|
{{svg "octicon-play"}} {{ctx.Locale.Tr "actions.actions"}}
|
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 10:45:19 +09:00
|
|
|
{{if .Repository.NumOpenActionRuns}}
|
2023-02-04 07:25:55 +09:00
|
|
|
<span class="ui small label">{{CountFmt .Repository.NumOpenActionRuns}}</span>
|
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 10:45:19 +09:00
|
|
|
{{end}}
|
|
|
|
</a>
|
|
|
|
{{end}}
|
|
|
|
|
2022-05-09 00:51:50 +09:00
|
|
|
{{if .Permission.CanRead $.UnitTypePackages}}
|
2022-12-09 22:34:51 +09:00
|
|
|
<a href="{{.RepoLink}}/packages" class="{{if .IsPackagesPage}}active {{end}}item">
|
2023-09-25 17:56:50 +09:00
|
|
|
{{svg "octicon-package"}} {{ctx.Locale.Tr "packages.title"}}
|
2022-05-09 00:51:50 +09:00
|
|
|
</a>
|
|
|
|
{{end}}
|
2022-03-30 17:42:47 +09:00
|
|
|
|
2022-08-26 06:55:52 +09:00
|
|
|
{{if and (not .UnitProjectsGlobalDisabled) (.Permission.CanRead $.UnitTypeProjects)}}
|
2022-12-09 22:34:51 +09:00
|
|
|
<a href="{{.RepoLink}}/projects" class="{{if .IsProjectsPage}}active {{end}}item">
|
2023-09-25 17:56:50 +09:00
|
|
|
{{svg "octicon-project"}} {{ctx.Locale.Tr "repo.project_board"}}
|
2020-10-24 20:54:33 +09:00
|
|
|
{{if .Repository.NumOpenProjects}}
|
2023-02-04 07:25:55 +09:00
|
|
|
<span class="ui small label">{{CountFmt .Repository.NumOpenProjects}}</span>
|
2020-10-24 20:54:33 +09:00
|
|
|
{{end}}
|
2020-08-17 12:07:38 +09:00
|
|
|
</a>
|
2022-08-26 06:55:52 +09:00
|
|
|
{{end}}
|
2020-08-17 12:07:38 +09:00
|
|
|
|
2022-08-26 06:55:52 +09:00
|
|
|
{{if and (.Permission.CanRead $.UnitTypeReleases) (not .IsEmptyRepo)}}
|
2023-07-05 13:11:42 +09:00
|
|
|
<a class="{{if or .PageIsReleaseList .PageIsTagList}}active {{end}}item" href="{{.RepoLink}}/releases">
|
2023-09-25 17:56:50 +09:00
|
|
|
{{svg "octicon-tag"}} {{ctx.Locale.Tr "repo.releases"}}
|
2020-10-24 20:54:33 +09:00
|
|
|
{{if .NumReleases}}
|
2023-02-04 07:25:55 +09:00
|
|
|
<span class="ui small label">{{CountFmt .NumReleases}}</span>
|
2020-10-24 20:54:33 +09:00
|
|
|
{{end}}
|
2017-10-15 08:17:39 +09:00
|
|
|
</a>
|
2019-10-13 22:23:14 +09:00
|
|
|
{{end}}
|
2017-10-15 08:17:39 +09:00
|
|
|
|
2023-04-25 01:28:37 +09:00
|
|
|
{{if .Permission.CanRead $.UnitTypeWiki}}
|
|
|
|
<a class="{{if .PageIsWiki}}active {{end}}item" href="{{.RepoLink}}/wiki">
|
2023-09-25 17:56:50 +09:00
|
|
|
{{svg "octicon-book"}} {{ctx.Locale.Tr "repo.wiki"}}
|
2019-10-13 22:23:14 +09:00
|
|
|
</a>
|
|
|
|
{{end}}
|
2018-01-10 15:19:50 +09:00
|
|
|
|
2023-04-25 01:28:37 +09:00
|
|
|
{{if .Permission.CanRead $.UnitTypeExternalWiki}}
|
|
|
|
<a class="item" href="{{(.Repository.MustGetUnit $.Context $.UnitTypeExternalWiki).ExternalWikiConfig.ExternalWikiURL}}" target="_blank" rel="noopener noreferrer">
|
2023-09-25 17:56:50 +09:00
|
|
|
{{svg "octicon-link-external"}} {{ctx.Locale.Tr "repo.wiki"}}
|
2023-04-25 01:28:37 +09:00
|
|
|
</a>
|
|
|
|
{{end}}
|
|
|
|
|
2019-10-13 22:23:14 +09:00
|
|
|
{{if and (.Permission.CanReadAny $.UnitTypePullRequests $.UnitTypeIssues $.UnitTypeReleases) (not .IsEmptyRepo)}}
|
2022-12-09 22:34:51 +09:00
|
|
|
<a class="{{if .PageIsActivity}}active {{end}}item" href="{{.RepoLink}}/activity">
|
2023-09-25 17:56:50 +09:00
|
|
|
{{svg "octicon-pulse"}} {{ctx.Locale.Tr "repo.activity"}}
|
2015-12-08 07:30:52 +09:00
|
|
|
</a>
|
2019-10-13 22:23:14 +09:00
|
|
|
{{end}}
|
|
|
|
|
|
|
|
{{template "custom/extra_tabs" .}}
|
|
|
|
|
[FEAT] Repository flags
This implements "repository flags", a way for instance administrators to
assign custom flags to repositories. The idea is that custom templates
can look at these flags, and display banners based on them, Forgejo does
not provide anything built on top of it, just the foundation. The
feature is optional, and disabled by default. To enable it, set
`[repository].ENABLE_FLAGS = true`.
On the UI side, instance administrators will see a new "Manage flags"
tab on repositories, and a list of enabled tags (if any) on the
repository home page. The "Manage flags" page allows them to remove
existing flags, or add any new ones that are listed in
`[repository].SETTABLE_FLAGS`.
The model does not enforce that only the `SETTABLE_FLAGS` are present.
If the setting is changed, old flags may remain present in the database,
and anything that uses them, will still work. The repository flag
management page will allow an instance administrator to remove them, but
not set them, once removed.
Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
(cherry picked from commit ba735ce2228f8dd7ca105e94b9baa1be058ebe37)
(cherry picked from commit f09f6e029b4fb2714b86cd32dc19255078ecc0ee)
(cherry picked from commit 2f8b0414892f6099f519bda63a9e0fbc8ba6cfc7)
(cherry picked from commit d3186ee5f41fac896c7d2341402fcd39dd250bf1)
2024-01-04 22:28:19 +09:00
|
|
|
{{if and RepoFlagsEnabled .SignedUser.IsAdmin}}
|
|
|
|
<a class="{{if .IsRepoFlagsPage}}active {{end}}item" href="{{.RepoLink}}/flags">
|
|
|
|
{{svg "octicon-milestone"}} {{ctx.Locale.Tr "repo.admin.manage_flags"}}
|
|
|
|
</a>
|
|
|
|
{{end}}
|
|
|
|
|
2019-10-13 22:23:14 +09:00
|
|
|
{{if .Permission.IsAdmin}}
|
[BUG] Load `AllUnitsEnabled` when necessary
- In order to determine if the "Add more..." tab should be shown, the
template has to know if the repository has all units enabled, this is
done in the repository header which can be shown for quite a lot of
pages (code, issues, projects, actions etc.)
- This was previously set in the `RepoRefByType` function, which would
be called by pages such as code, issues and releases, but it was not
being called for all pages such as actions, packages and wiki. Which
would in turn incorrectly show the "Add more..." button when it
shouldn't.
- Now call it from the template itself, so the value is 'always' loaded
when necessary.
2024-02-21 20:42:12 +09:00
|
|
|
{{if not (.Repository.AllUnitsEnabled ctx)}}
|
2024-01-23 18:57:49 +09:00
|
|
|
<a class="{{if .PageIsRepoSettingsUnits}}active {{end}}item" href="{{.RepoLink}}/settings/units">
|
|
|
|
{{svg "octicon-diff-added"}} {{ctx.Locale.Tr "repo.settings.units.add_more"}}
|
|
|
|
</a>
|
|
|
|
{{end}}
|
2024-02-29 12:17:53 +09:00
|
|
|
<a class="{{if and .PageIsRepoSettings (not .PageIsRepoSettingsUnits)}}active {{end}} item" href="{{.RepoLink}}/settings">
|
2023-09-25 17:56:50 +09:00
|
|
|
{{svg "octicon-tools"}} {{ctx.Locale.Tr "repo.settings"}}
|
2023-04-29 20:35:59 +09:00
|
|
|
</a>
|
2019-10-13 22:23:14 +09:00
|
|
|
{{end}}
|
|
|
|
</div>
|
2021-11-23 07:32:16 +09:00
|
|
|
{{else if .Permission.IsAdmin}}
|
2024-03-15 11:05:31 +09:00
|
|
|
<div class="overflow-menu-items">
|
2024-01-12 12:44:06 +09:00
|
|
|
<a class="{{if .PageIsRepoSettings}}active {{end}} item" href="{{.RepoLink}}/settings">
|
2023-09-25 17:56:50 +09:00
|
|
|
{{svg "octicon-tools"}} {{ctx.Locale.Tr "repo.settings"}}
|
2023-04-29 20:35:59 +09:00
|
|
|
</a>
|
2021-11-23 07:32:16 +09:00
|
|
|
</div>
|
2019-10-13 22:23:14 +09:00
|
|
|
{{end}}
|
2024-03-15 11:05:31 +09:00
|
|
|
</overflow-menu>
|
2015-12-08 07:30:52 +09:00
|
|
|
<div class="ui tabs divider"></div>
|
2016-03-05 04:50:34 +09:00
|
|
|
</div>
|