2016-02-15 04:56:47 +05:30
|
|
|
<div class="header-wrapper">
|
2014-10-19 11:05:24 +05:30
|
|
|
{{with .Repository}}
|
2017-12-31 06:17:52 +05:30
|
|
|
<div class="ui container">
|
2019-02-06 03:29:26 +05:30
|
|
|
<div class="repo-header">
|
2023-02-13 23:29:59 +05:30
|
|
|
<div class="repo-title-wrap gt-df gt-fc">
|
2023-02-12 17:50:12 +05:30
|
|
|
<div class="repo-title" role="heading" aria-level="1">
|
2023-02-13 23:29:59 +05:30
|
|
|
{{$avatar := (repoAvatar . 32 "gt-mr-3")}}
|
2020-12-08 09:44:28 +05:30
|
|
|
{{if $avatar}}
|
|
|
|
{{$avatar}}
|
2020-06-23 01:50:51 +05:30
|
|
|
{{else}}
|
2020-12-08 09:44:28 +05:30
|
|
|
{{template "repo/icon" .}}
|
2020-06-23 01:50:51 +05:30
|
|
|
{{end}}
|
2021-11-16 23:48:25 +05:30
|
|
|
<a href="{{.Owner.HomeLink}}">{{.Owner.Name}}</a>
|
2023-02-13 23:29:59 +05:30
|
|
|
<div class="gt-mx-2">/</div>
|
2020-12-08 09:44:28 +05:30
|
|
|
<a href="{{$.RepoLink}}">{{.Name}}</a>
|
2022-11-21 10:44:58 +05:30
|
|
|
{{if $.EnableFeed}}
|
2023-03-24 16:05:38 +05:30
|
|
|
<a href="{{$.RepoLink}}.rss"><i class="ui grey icon gt-ml-3" data-tooltip-content="{{$.locale.Tr "rss_feed"}}">{{svg "octicon-rss" 18}}</i></a>
|
2022-11-21 10:44:58 +05:30
|
|
|
{{end}}
|
2023-02-13 23:29:59 +05:30
|
|
|
<div class="labels gt-df gt-ac gt-fw">
|
2020-12-08 09:44:28 +05:30
|
|
|
{{if .IsTemplate}}
|
|
|
|
{{if .IsPrivate}}
|
2022-06-28 02:28:46 +05:30
|
|
|
<span class="ui basic label">{{$.locale.Tr "repo.desc.private_template"}}</span>
|
2020-12-08 09:44:28 +05:30
|
|
|
{{else}}
|
|
|
|
{{if .Owner.Visibility.IsPrivate}}
|
2022-06-28 02:28:46 +05:30
|
|
|
<span class="ui basic label">{{$.locale.Tr "repo.desc.internal_template"}}</span>
|
2020-12-08 09:44:28 +05:30
|
|
|
{{end}}
|
|
|
|
{{end}}
|
|
|
|
{{else}}
|
|
|
|
{{if .IsPrivate}}
|
2022-06-28 02:28:46 +05:30
|
|
|
<span class="ui basic label">{{$.locale.Tr "repo.desc.private"}}</span>
|
2020-12-08 09:44:28 +05:30
|
|
|
{{else}}
|
|
|
|
{{if .Owner.Visibility.IsPrivate}}
|
2022-06-28 02:28:46 +05:30
|
|
|
<span class="ui basic label">{{$.locale.Tr "repo.desc.internal"}}</span>
|
2020-12-08 09:44:28 +05:30
|
|
|
{{end}}
|
|
|
|
{{end}}
|
2020-06-23 01:50:51 +05:30
|
|
|
{{end}}
|
2020-12-08 09:44:28 +05:30
|
|
|
{{if .IsArchived}}
|
2022-06-28 02:28:46 +05:30
|
|
|
<span class="ui basic label">{{$.locale.Tr "repo.desc.archived"}}</span>
|
2020-12-08 09:44:28 +05:30
|
|
|
{{end}}
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-06-13 21:42:59 +05:30
|
|
|
{{if $.IsPullMirror}}
|
2022-08-15 08:42:01 +05:30
|
|
|
{{$address := MirrorRemoteAddress $.Context . $.Mirror.GetRemoteName false}}
|
2022-06-28 02:28:46 +05:30
|
|
|
<div class="fork-flag">{{$.locale.Tr "repo.mirror_from"}} <a target="_blank" rel="noopener noreferrer" href="{{$address.Address}}">{{$address.Address}}</a></div>
|
2022-06-13 21:42:59 +05:30
|
|
|
{{end}}
|
2022-06-28 02:28:46 +05:30
|
|
|
{{if .IsFork}}<div class="fork-flag">{{$.locale.Tr "repo.forked_from"}} <a href="{{.BaseRepo.Link}}">{{.BaseRepo.FullName}}</a></div>{{end}}
|
|
|
|
{{if .IsGenerated}}<div class="fork-flag">{{$.locale.Tr "repo.generated_from"}} <a href="{{.TemplateRepo.Link}}">{{.TemplateRepo.FullName}}</a></div>{{end}}
|
2017-12-31 06:17:52 +05:30
|
|
|
</div>
|
2021-11-23 04:02:16 +05:30
|
|
|
{{if not (or .IsBeingCreated .IsBroken)}}
|
2019-10-13 18:53:14 +05:30
|
|
|
<div class="repo-buttons">
|
2021-03-01 06:17:30 +05:30
|
|
|
{{if $.RepoTransfer}}
|
|
|
|
<form method="post" action="{{$.RepoLink}}/action/accept_transfer?redirect_to={{$.RepoLink}}">
|
|
|
|
{{$.CsrfTokenHtml}}
|
2023-03-24 16:05:38 +05:30
|
|
|
<div data-tooltip-content="{{if $.CanUserAcceptTransfer}}{{$.locale.Tr "repo.transfer.accept_desc" $.RepoTransfer.Recipient.DisplayName}}{{else}}{{$.locale.Tr "repo.transfer.no_permission_to_accept"}}{{end}}">
|
2021-03-01 06:17:30 +05:30
|
|
|
<button type="submit" class="ui button {{if $.CanUserAcceptTransfer}}green {{end}} ok inverted small"{{if not $.CanUserAcceptTransfer}} disabled{{end}}>
|
2022-06-28 02:28:46 +05:30
|
|
|
{{$.locale.Tr "repo.transfer.accept"}}
|
2021-03-01 06:17:30 +05:30
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
<form method="post" action="{{$.RepoLink}}/action/reject_transfer?redirect_to={{$.RepoLink}}">
|
|
|
|
{{$.CsrfTokenHtml}}
|
2023-03-24 16:05:38 +05:30
|
|
|
<div data-tooltip-content="{{if $.CanUserAcceptTransfer}}{{$.locale.Tr "repo.transfer.reject_desc" $.RepoTransfer.Recipient.DisplayName}}{{else}}{{$.locale.Tr "repo.transfer.no_permission_to_reject"}}{{end}}">
|
2021-03-01 06:17:30 +05:30
|
|
|
<button type="submit" class="ui button {{if $.CanUserAcceptTransfer}}red {{end}}ok inverted small"{{if not $.CanUserAcceptTransfer}} disabled{{end}}>
|
2022-06-28 02:28:46 +05:30
|
|
|
{{$.locale.Tr "repo.transfer.reject"}}
|
2021-03-01 06:17:30 +05:30
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
{{end}}
|
2020-02-26 01:58:47 +05:30
|
|
|
<form method="post" action="{{$.RepoLink}}/action/{{if $.IsWatchingRepo}}un{{end}}watch?redirect_to={{$.Link}}">
|
|
|
|
{{$.CsrfTokenHtml}}
|
2023-03-24 16:05:38 +05:30
|
|
|
<div class="ui labeled button" {{if not $.IsSigned}}data-tooltip-content="{{$.locale.Tr "repo.watch_guest_user"}}"{{end}}>
|
2020-12-27 16:23:53 +05:30
|
|
|
<button type="submit" class="ui compact small basic button"{{if not $.IsSigned}} disabled{{end}}>
|
2022-06-28 02:28:46 +05:30
|
|
|
{{if $.IsWatchingRepo}}{{svg "octicon-eye-closed" 16}}{{$.locale.Tr "repo.unwatch"}}{{else}}{{svg "octicon-eye"}}{{$.locale.Tr "repo.watch"}}{{end}}
|
2020-02-26 01:58:47 +05:30
|
|
|
</button>
|
|
|
|
<a class="ui basic label" href="{{.Link}}/watchers">
|
2020-09-16 09:37:18 +05:30
|
|
|
{{CountFmt .NumWatches}}
|
2020-02-26 01:58:47 +05:30
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</form>
|
2021-04-15 22:23:57 +05:30
|
|
|
{{if not $.DisableStars}}
|
|
|
|
<form method="post" action="{{$.RepoLink}}/action/{{if $.IsStaringRepo}}un{{end}}star?redirect_to={{$.Link}}">
|
|
|
|
{{$.CsrfTokenHtml}}
|
2023-03-24 16:05:38 +05:30
|
|
|
<div class="ui labeled button" {{if not $.IsSigned}}data-tooltip-content="{{$.locale.Tr "repo.star_guest_user"}}"{{end}}>
|
2021-04-15 22:23:57 +05:30
|
|
|
<button type="submit" class="ui compact small basic button"{{if not $.IsSigned}} disabled{{end}}>
|
2022-06-28 02:28:46 +05:30
|
|
|
{{if $.IsStaringRepo}}{{svg "octicon-star-fill"}}{{$.locale.Tr "repo.unstar"}}{{else}}{{svg "octicon-star"}}{{$.locale.Tr "repo.star"}}{{end}}
|
2021-04-15 22:23:57 +05:30
|
|
|
</button>
|
|
|
|
<a class="ui basic label" href="{{.Link}}/stars">
|
|
|
|
{{CountFmt .NumStars}}
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
{{end}}
|
2019-10-13 18:53:14 +05:30
|
|
|
{{if and (not .IsEmpty) ($.Permission.CanRead $.UnitTypeCode)}}
|
2021-12-13 07:29:09 +05:30
|
|
|
<div class="ui labeled button
|
|
|
|
{{if or (not $.IsSigned) (and (not $.CanSignedUserFork) (eq (len $.UserAndOrgForks) 0))}}
|
2023-03-24 16:05:38 +05:30
|
|
|
disabled
|
2021-12-13 07:29:09 +05:30
|
|
|
{{end}}"
|
|
|
|
{{if not $.IsSigned}}
|
2023-03-24 16:05:38 +05:30
|
|
|
data-tooltip-content="{{$.locale.Tr "repo.fork_guest_user"}}"
|
2021-12-13 07:29:09 +05:30
|
|
|
{{else if and (not $.CanSignedUserFork) (eq (len $.UserAndOrgForks) 0)}}
|
2023-03-24 16:05:38 +05:30
|
|
|
data-tooltip-content="{{$.locale.Tr "repo.fork_from_self"}}"
|
2021-12-13 07:29:09 +05:30
|
|
|
{{end}}
|
2023-03-24 16:05:38 +05:30
|
|
|
>
|
2021-12-13 07:29:09 +05:30
|
|
|
<a class="ui compact{{if $.ShowForkModal}} show-modal{{end}} small basic button"
|
|
|
|
{{if not $.CanSignedUserFork}}
|
|
|
|
{{if gt (len $.UserAndOrgForks) 1}}
|
|
|
|
data-modal="#fork-repo-modal"
|
|
|
|
{{else if eq (len $.UserAndOrgForks) 1}}
|
|
|
|
href="{{AppSubUrl}}/{{(index $.UserAndOrgForks 0).FullName}}"
|
|
|
|
{{/*else is not required here, because the button shouldn't link to any site if you can't create a fork*/}}
|
|
|
|
{{end}}
|
|
|
|
{{else if eq (len $.UserAndOrgForks) 0}}
|
|
|
|
href="{{AppSubUrl}}/repo/fork/{{.ID}}"
|
|
|
|
{{else}}
|
|
|
|
data-modal="#fork-repo-modal"
|
|
|
|
{{end}}
|
|
|
|
>
|
2022-06-28 02:28:46 +05:30
|
|
|
{{svg "octicon-repo-forked"}}{{$.locale.Tr "repo.fork"}}
|
2019-10-13 18:53:14 +05:30
|
|
|
</a>
|
2021-12-13 07:29:09 +05:30
|
|
|
<div class="ui small modal" id="fork-repo-modal">
|
|
|
|
{{svg "octicon-x" 16 "close inside"}}
|
|
|
|
<div class="header">
|
2022-06-28 02:28:46 +05:30
|
|
|
{{$.locale.Tr "repo.already_forked" .Name}}
|
2021-12-13 07:29:09 +05:30
|
|
|
</div>
|
2023-02-13 23:29:59 +05:30
|
|
|
<div class="content gt-tl">
|
2021-12-13 07:29:09 +05:30
|
|
|
<div class="ui list">
|
|
|
|
{{range $.UserAndOrgForks}}
|
2023-02-13 23:29:59 +05:30
|
|
|
<div class="ui item gt-py-3">
|
2021-12-13 07:29:09 +05:30
|
|
|
<a href="{{.Link}}">
|
2023-02-13 23:29:59 +05:30
|
|
|
{{svg "octicon-repo-forked" 16 "gt-mr-3"}}{{.FullName}}
|
2021-12-13 07:29:09 +05:30
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
{{end}}
|
|
|
|
</div>
|
|
|
|
{{if $.CanSignedUserFork}}
|
|
|
|
<div class="ui divider"></div>
|
|
|
|
<a href="{{AppSubUrl}}/repo/fork/{{.ID}}">
|
2022-06-28 02:28:46 +05:30
|
|
|
{{$.locale.Tr "repo.fork_to_different_account"}}
|
2021-12-13 07:29:09 +05:30
|
|
|
</a>
|
|
|
|
{{end}}
|
|
|
|
</div>
|
|
|
|
</div>
|
2019-10-13 18:53:14 +05:30
|
|
|
<a class="ui basic label" href="{{.Link}}/forks">
|
2020-09-16 09:37:18 +05:30
|
|
|
{{CountFmt .NumForks}}
|
2019-10-13 18:53:14 +05:30
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
{{end}}
|
|
|
|
</div>
|
|
|
|
{{end}}
|
2016-02-15 04:56:47 +05:30
|
|
|
</div><!-- end grid -->
|
|
|
|
</div><!-- end container -->
|
2015-08-12 15:42:06 +05:30
|
|
|
{{end}}
|
2022-04-27 02:01:58 +05:30
|
|
|
<div class="ui tabs container">
|
2021-11-23 04:02:16 +05:30
|
|
|
{{if not (or .Repository.IsBeingCreated .Repository.IsBroken)}}
|
2019-10-13 18:53:14 +05:30
|
|
|
<div class="ui tabular stackable menu navbar">
|
|
|
|
{{if .Permission.CanRead $.UnitTypeCode}}
|
2022-12-09 19:04:51 +05:30
|
|
|
<a class="{{if .PageIsViewCode}}active {{end}}item" href="{{.RepoLink}}{{if (ne .BranchName .Repository.DefaultBranch)}}/src/{{.BranchNameSubURL}}{{end}}">
|
2022-06-28 02:28:46 +05:30
|
|
|
{{svg "octicon-code"}} {{.locale.Tr "repo.code"}}
|
2017-02-04 21:23:46 +05:30
|
|
|
</a>
|
2019-10-13 18:53:14 +05:30
|
|
|
{{end}}
|
2017-03-18 16:29:07 +05:30
|
|
|
|
2019-10-13 18:53:14 +05:30
|
|
|
{{if .Permission.CanRead $.UnitTypeIssues}}
|
2022-12-09 19:04:51 +05:30
|
|
|
<a class="{{if .PageIsIssueList}}active {{end}}item" href="{{.RepoLink}}/issues">
|
2022-06-28 02:28:46 +05:30
|
|
|
{{svg "octicon-issue-opened"}} {{.locale.Tr "repo.issues"}}
|
2020-10-24 17:24:33 +05:30
|
|
|
{{if .Repository.NumOpenIssues}}
|
2023-02-04 03:55:55 +05:30
|
|
|
<span class="ui small label">{{CountFmt .Repository.NumOpenIssues}}</span>
|
2020-10-24 17:24:33 +05:30
|
|
|
{{end}}
|
2019-10-13 18:53:14 +05:30
|
|
|
</a>
|
|
|
|
{{end}}
|
2017-02-04 21:23:46 +05:30
|
|
|
|
2019-10-13 18:53:14 +05:30
|
|
|
{{if .Permission.CanRead $.UnitTypeExternalTracker}}
|
2022-12-09 19:04:51 +05:30
|
|
|
<a class="{{if .PageIsIssueList}}active {{end}}item" href="{{.RepoExternalIssuesLink}}" target="_blank" rel="noopener noreferrer">
|
2022-06-28 02:28:46 +05:30
|
|
|
{{svg "octicon-link-external"}} {{.locale.Tr "repo.issues"}} </span>
|
2019-10-13 18:53:14 +05:30
|
|
|
</a>
|
|
|
|
{{end}}
|
2017-02-04 21:23:46 +05:30
|
|
|
|
2019-10-13 18:53:14 +05:30
|
|
|
{{if and .Repository.CanEnablePulls (.Permission.CanRead $.UnitTypePullRequests)}}
|
2022-12-09 19:04:51 +05:30
|
|
|
<a class="{{if .PageIsPullList}}active {{end}}item" href="{{.RepoLink}}/pulls">
|
2022-06-28 02:28:46 +05:30
|
|
|
{{svg "octicon-git-pull-request"}} {{.locale.Tr "repo.pulls"}}
|
2020-10-24 17:24:33 +05:30
|
|
|
{{if .Repository.NumOpenPulls}}
|
2023-02-04 03:55:55 +05:30
|
|
|
<span class="ui small label">{{CountFmt .Repository.NumOpenPulls}}</span>
|
2020-10-24 17:24:33 +05:30
|
|
|
{{end}}
|
2019-10-13 18:53:14 +05:30
|
|
|
</a>
|
|
|
|
{{end}}
|
2017-02-04 21:23:46 +05:30
|
|
|
|
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 and .EnableActions (not .UnitActionsGlobalDisabled) (.Permission.CanRead $.UnitTypeActions)}}
|
|
|
|
<a class="{{if .PageIsActions}}active {{end}}item" href="{{.RepoLink}}/actions">
|
|
|
|
{{svg "octicon-play"}} {{.locale.Tr "actions.actions"}}
|
|
|
|
{{if .Repository.NumOpenActionRuns}}
|
2023-02-04 03:55:55 +05:30
|
|
|
<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 07:15:19 +05:30
|
|
|
{{end}}
|
|
|
|
</a>
|
|
|
|
{{end}}
|
|
|
|
|
2022-05-08 21:21:50 +05:30
|
|
|
{{if .Permission.CanRead $.UnitTypePackages}}
|
2022-12-09 19:04:51 +05:30
|
|
|
<a href="{{.RepoLink}}/packages" class="{{if .IsPackagesPage}}active {{end}}item">
|
2022-06-28 02:28:46 +05:30
|
|
|
{{svg "octicon-package"}} {{.locale.Tr "packages.title"}}
|
2022-05-08 21:21:50 +05:30
|
|
|
</a>
|
|
|
|
{{end}}
|
2022-03-30 14:12:47 +05:30
|
|
|
|
2022-08-26 03:25:52 +05:30
|
|
|
{{if and (not .UnitProjectsGlobalDisabled) (.Permission.CanRead $.UnitTypeProjects)}}
|
2022-12-09 19:04:51 +05:30
|
|
|
<a href="{{.RepoLink}}/projects" class="{{if .IsProjectsPage}}active {{end}}item">
|
2022-06-28 02:28:46 +05:30
|
|
|
{{svg "octicon-project"}} {{.locale.Tr "repo.project_board"}}
|
2020-10-24 17:24:33 +05:30
|
|
|
{{if .Repository.NumOpenProjects}}
|
2023-02-04 03:55:55 +05:30
|
|
|
<span class="ui small label">{{CountFmt .Repository.NumOpenProjects}}</span>
|
2020-10-24 17:24:33 +05:30
|
|
|
{{end}}
|
2020-08-17 08:37:38 +05:30
|
|
|
</a>
|
2022-08-26 03:25:52 +05:30
|
|
|
{{end}}
|
2020-08-17 08:37:38 +05:30
|
|
|
|
2022-08-26 03:25:52 +05:30
|
|
|
{{if and (.Permission.CanRead $.UnitTypeReleases) (not .IsEmptyRepo)}}
|
2022-12-09 19:04:51 +05:30
|
|
|
<a class="{{if .PageIsReleaseList}}active {{end}}item" href="{{.RepoLink}}/releases">
|
2022-06-28 02:28:46 +05:30
|
|
|
{{svg "octicon-tag"}} {{.locale.Tr "repo.releases"}}
|
2020-10-24 17:24:33 +05:30
|
|
|
{{if .NumReleases}}
|
2023-02-04 03:55:55 +05:30
|
|
|
<span class="ui small label">{{CountFmt .NumReleases}}</span>
|
2020-10-24 17:24:33 +05:30
|
|
|
{{end}}
|
2017-10-15 04:47:39 +05:30
|
|
|
</a>
|
2019-10-13 18:53:14 +05:30
|
|
|
{{end}}
|
2017-10-15 04:47:39 +05:30
|
|
|
|
2019-10-13 18:53:14 +05:30
|
|
|
{{if or (.Permission.CanRead $.UnitTypeWiki) (.Permission.CanRead $.UnitTypeExternalWiki)}}
|
2023-04-22 23:46:22 +05:30
|
|
|
<a class="{{if .PageIsWiki}}active {{end}}item" href="{{.RepoLink}}/wiki" {{if and (.Permission.CanRead $.UnitTypeExternalWiki) (not (StringUtils.HasPrefix ((.Repository.MustGetUnit $.Context $.UnitTypeExternalWiki).ExternalWikiConfig.ExternalWikiURL) (.Repository.Link)))}} target="_blank" rel="noopener noreferrer" {{end}}>
|
2022-06-28 02:28:46 +05:30
|
|
|
{{svg "octicon-book"}} {{.locale.Tr "repo.wiki"}}
|
2019-10-13 18:53:14 +05:30
|
|
|
</a>
|
|
|
|
{{end}}
|
2018-01-10 11:49:50 +05:30
|
|
|
|
2019-10-13 18:53:14 +05:30
|
|
|
{{if and (.Permission.CanReadAny $.UnitTypePullRequests $.UnitTypeIssues $.UnitTypeReleases) (not .IsEmptyRepo)}}
|
2022-12-09 19:04:51 +05:30
|
|
|
<a class="{{if .PageIsActivity}}active {{end}}item" href="{{.RepoLink}}/activity">
|
2022-06-28 02:28:46 +05:30
|
|
|
{{svg "octicon-pulse"}} {{.locale.Tr "repo.activity"}}
|
2015-12-08 04:00:52 +05:30
|
|
|
</a>
|
2019-10-13 18:53:14 +05:30
|
|
|
{{end}}
|
|
|
|
|
|
|
|
{{template "custom/extra_tabs" .}}
|
|
|
|
|
|
|
|
{{if .Permission.IsAdmin}}
|
|
|
|
<div class="right menu">
|
2022-12-09 19:04:51 +05:30
|
|
|
<a class="{{if .PageIsSettings}}active {{end}}item" href="{{.RepoLink}}/settings">
|
2022-06-28 02:28:46 +05:30
|
|
|
{{svg "octicon-tools"}} {{.locale.Tr "repo.settings"}}
|
2019-10-13 18:53:14 +05:30
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
{{end}}
|
|
|
|
</div>
|
2021-11-23 04:02:16 +05:30
|
|
|
{{else if .Permission.IsAdmin}}
|
|
|
|
<div class="ui tabular stackable menu navbar">
|
|
|
|
<div class="right menu">
|
2022-12-09 19:04:51 +05:30
|
|
|
<a class="{{if .PageIsSettings}}active {{end}}item" href="{{.RepoLink}}/settings">
|
2022-06-28 02:28:46 +05:30
|
|
|
{{svg "octicon-tools"}} {{.locale.Tr "repo.settings"}}
|
2021-11-23 04:02:16 +05:30
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
2019-10-13 18:53:14 +05:30
|
|
|
{{end}}
|
2015-12-08 04:00:52 +05:30
|
|
|
</div>
|
|
|
|
<div class="ui tabs divider"></div>
|
2016-03-05 01:20:34 +05:30
|
|
|
</div>
|