A hub on Gitea or Forgejo¶
Gitea 1.26 and newer, Forgejo 15 and newer, self-hosted or hosted.
Gitea and Forgejo Actions can't limit a secret to the default branch: every branch's jobs
see every Actions secret, and environment is ignored. So touchmark won't use their CI
with security.write_isolation: platform. Pick one:
- Deliver from GitHub or GitLab (recommended). Run the hub's CI on GitHub or GitLab,
and deliver to Gitea or Forgejo from there: add them as
providersinhub.yml, and their keys next to the others, in the protected environment or variable. See Deliver to several platforms. - Host the hub on Gitea or Forgejo with
security.write_isolation: noneand areason, and protect every branch (*) so that only maintainers can push. Contributors then work from forks, which receive no secrets.
# hub.yml of a hub hosted on Forgejo
version: 1
id: acme-eng
providers:
- id: cb
type: forgejo
url: https://codeberg.org
writer: acme-touchmark
security:
write_isolation: none
reason: "Forgejo Actions cannot keep a secret to one branch; every branch is protected and only maintainers push"
A hub on Gitea or Forgejo¶
- Create the hub by migrating the template.
- Create two bot users: a reader in a team with read access and a writer in a team
with write access to your repositories. Give the teams your target repositories one by
one, not all repositories of the organisation, which would include the hub.
- Reader token:
read:repository, read:issue, read:organization, read:user. - Writer token:
write:repository, write:issue, read:organization, read:user. - Never use an admin token: touchmark refuses it, because through
Sudoit acts as anyone. - Store them as the Actions secrets
TOUCHMARK_READ_TOKENandTOUCHMARK_WRITE_TOKEN.
- Reader token:
- Check the runner label. The workflows in
.gitea/workflows/run onubuntu-latest, the label of Gitea's default runners. If your runners are registered with other labels, changeruns-on. Every job runs in the touchmark image and clones the hub with git, so it needs no actions from github.com or a mirror. The report is in the job's log, and on Gitea 1.27 with runner 2.0 in its summary. - Protect the hub with a branch protection on
*that lets only maintainers push, and replace@acme/hub-maintainersin.gitea/CODEOWNERSwith your team. - Describe your hub. Set
id,providers(withurl: Gitea and Forgejo have no default instance) andsecurityinhub.yml, then open a pull request and merge it.distributeruns on every merge tomainormaster(add your default branch underpush: branches:if it has another name) and every day;doctorevery Monday, from.gitea/workflows/engineering-assets-doctor.yml.
Notes¶
- Bot users on Gitea 1.26 created with
admin user create --user-type botmust change their password first, and their tokens get 403 on every request until the flag is cleared:gitea admin user must-change-password --unset <login>. WithTWO_FACTOR_AUTH=enforced, the bot needs TOTP. - Tokens of Gitea and Forgejo do not expire;
doctorchecks their scopes on Gitea 1.27 and reports the expiry asok. - Drafts are the
WIP:title prefix on Gitea and Forgejo; setpr.draft: true, never the prefix inpr.title. - Instances that require sign-in to view anything (
REQUIRE_SIGNIN_VIEW) count as non-public: a public hub skips their repositories.
Next: opt a repository in.