codefloe/forgejo-codefloe
Watch
4
12
Fork
You've already forked forgejo-codefloe
0

feat(pages): publish additional branches beside the main site #227

Merged
pat-s merged 1 commit from feat/pages-branch-sites into v16.0/forgejo-codefloe 2026-10-17 09:19:49 +00:00
Owner

Implements the forum request Support multiple branches for Pages.

What

On the git-pages backend, a repository can publish up to five branches beside its main Pages branch.
Each one is served at https://<owner>.codefloe.page/<repo>@<branch>/, for example https://ma-writes.codefloe.page/amu-vault@dev/.
A push to the branch republishes it, deleting the branch unpublishes it, and disabling Pages or deleting the repository removes all of them.
Custom domains keep serving the main branch.

How

git-pages only serves a site from one path segment, and it authorises every upload by asking the forge whether the token may push to <owner>/<site>.
So a branch site is published under the site name <repo>@<branch>, and GET /api/v1/repos/<owner>/<repo>@<branch> answers with the repository while that branch is recorded as published.
No repository name can contain @, so the alias cannot shadow a real repository.
Only that exact GET is answered: sub-routes and other methods on the alias still return 404.
This needs no change to git-pages or to the nodes' config.

  • New repo_pages_branch table (codefloe migration v21), unique on (repo_pages_id, branch).
  • archiveBranch archives the branch named in a <repo>@<branch> site handle.
  • API: PUT/DELETE /repos/{owner}/{repo}/pages/branches/{branch}, and branches in the RepoPages response.
  • Settings page: new "Additional branches" section to publish and unpublish branches.
  • forgejo admin pages publish also republishes branch sites.
  • Branch names are limited to letters, digits, ., _ and -, because a / would be a second path segment.
  • The main branch cannot be moved onto a branch that is already published as an additional one.

Testing

  • Unit tests for the module helpers, the service (publishing, refusals, limit, unpublish ordering, teardown, alias resolution) and the migration.
  • Integration test TestAPIPagesBranchSites covers the endpoints and the alias's scope.
  • Checked the settings page in the e2e debug server (empty, two branches, narrow viewport).

After deploy

Publish a branch on a test repository and confirm the git-pages upload goes through, since that is the first time the alias is exercised by a real node.
The Pages docs on docs.codefloe.com should mention the @<branch> address.

Implements the forum request [Support multiple branches for Pages](https://forum.codefloe.com/t/feature-request-support-multiple-branches-for-pages/214). ## What On the git-pages backend, a repository can publish up to five branches beside its main Pages branch. Each one is served at `https://<owner>.codefloe.page/<repo>@<branch>/`, for example `https://ma-writes.codefloe.page/amu-vault@dev/`. A push to the branch republishes it, deleting the branch unpublishes it, and disabling Pages or deleting the repository removes all of them. Custom domains keep serving the main branch. ## How git-pages only serves a site from one path segment, and it authorises every upload by asking the forge whether the token may push to `<owner>/<site>`. So a branch site is published under the site name `<repo>@<branch>`, and `GET /api/v1/repos/<owner>/<repo>@<branch>` answers with the repository while that branch is recorded as published. No repository name can contain `@`, so the alias cannot shadow a real repository. Only that exact GET is answered: sub-routes and other methods on the alias still return 404. This needs no change to git-pages or to the nodes' config. - New `repo_pages_branch` table (codefloe migration v21), unique on `(repo_pages_id, branch)`. - `archiveBranch` archives the branch named in a `<repo>@<branch>` site handle. - API: `PUT`/`DELETE /repos/{owner}/{repo}/pages/branches/{branch}`, and `branches` in the `RepoPages` response. - Settings page: new "Additional branches" section to publish and unpublish branches. - `forgejo admin pages publish` also republishes branch sites. - Branch names are limited to letters, digits, `.`, `_` and `-`, because a `/` would be a second path segment. - The main branch cannot be moved onto a branch that is already published as an additional one. ## Testing - Unit tests for the module helpers, the service (publishing, refusals, limit, unpublish ordering, teardown, alias resolution) and the migration. - Integration test `TestAPIPagesBranchSites` covers the endpoints and the alias's scope. - Checked the settings page in the e2e debug server (empty, two branches, narrow viewport). ## After deploy Publish a branch on a test repository and confirm the git-pages upload goes through, since that is the first time the alias is exercised by a real node. The Pages docs on docs.codefloe.com should mention the `@<branch>` address.
feat(pages): publish additional branches beside the main site
Some checks failed
testing / test-unit (pull_request) Has been cancelled
testing / test-e2e (1/2) (pull_request) Has been cancelled
testing / test-e2e (2/2) (pull_request) Has been cancelled
testing / test-pgsql (1/4) (pull_request) Has been cancelled
testing / frontend-checks (pull_request) Has been cancelled
testing / test-pgsql (2/4) (pull_request) Has been cancelled
testing / test-pgsql (3/4) (pull_request) Has been cancelled
testing / test-pgsql (4/4) (pull_request) Has been cancelled
testing / backend-checks (pull_request) Has been cancelled
0a6eeeefa8
Let a repository on the git-pages backend publish up to five more
branches, each at <owner>.<domain>/<repo>@<branch>/, republished on push
and unpublished when the branch is deleted or Pages is disabled.

git-pages authorises a publish by asking the forge whether the token may
push to <owner>/<site>, so the repository API answers a GET for
<repo>@<branch> while that branch is recorded as published. No repository
name can contain "@", so the alias cannot shadow one.

- add the repo_pages_branch table and migration
- archive the named branch for a <repo>@<branch> site handle
- add PUT/DELETE /repos/{owner}/{repo}/pages/branches/{branch} and list
  branches in the Pages API response
- add an "Additional branches" section to the Pages settings page
- republish branch sites from `forgejo admin pages publish`
pat-s force-pushed feat/pages-branch-sites from 0a6eeeefa8
Some checks failed
testing / test-unit (pull_request) Has been cancelled
testing / test-e2e (1/2) (pull_request) Has been cancelled
testing / test-e2e (2/2) (pull_request) Has been cancelled
testing / test-pgsql (1/4) (pull_request) Has been cancelled
testing / frontend-checks (pull_request) Has been cancelled
testing / test-pgsql (2/4) (pull_request) Has been cancelled
testing / test-pgsql (3/4) (pull_request) Has been cancelled
testing / test-pgsql (4/4) (pull_request) Has been cancelled
testing / backend-checks (pull_request) Has been cancelled
to 6aa1f1ebdc
All checks were successful
testing / frontend-checks (pull_request) Successful in 2m2s
testing / test-e2e (2/2) (pull_request) Successful in 4m48s
testing / backend-checks (pull_request) Successful in 8m19s
testing / test-e2e (1/2) (pull_request) Successful in 4m55s
testing / test-unit (pull_request) Successful in 9m17s
testing / test-pgsql (2/4) (pull_request) Successful in 9m21s
testing / test-pgsql (4/4) (pull_request) Successful in 11m7s
testing / test-pgsql (1/4) (pull_request) Successful in 11m29s
testing / test-pgsql (3/4) (pull_request) Successful in 11m52s
issue-labels / backporting (pull_request_target) Has been skipped
milestone / set (pull_request_target) Has been skipped
2026-10-17 08:45:15 +00:00
Compare
pat-s merged commit 4afb068af7 into v16.0/forgejo-codefloe 2026-10-17 09:19:49 +00:00
pat-s deleted branch feat/pages-branch-sites 2026-10-17 09:19:50 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
codefloe/forgejo-codefloe!227
No description provided.