feat(pages): publish additional branches beside the main site #227
No reviewers
Labels
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
codefloe/forgejo-codefloe!227
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/pages-branch-sites"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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 examplehttps://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>, andGET /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.
repo_pages_branchtable (codefloe migration v21), unique on(repo_pages_id, branch).archiveBrancharchives the branch named in a<repo>@<branch>site handle.PUT/DELETE /repos/{owner}/{repo}/pages/branches/{branch}, andbranchesin theRepoPagesresponse.forgejo admin pages publishalso republishes branch sites..,_and-, because a/would be a second path segment.Testing
TestAPIPagesBranchSitescovers the endpoints and the alias's scope.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.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`0a6eeeefa86aa1f1ebdc