Document the Gitea org-wide, org-defined, and per-repo options as equals
Test / Test (push) Successful in 16s
Test / Test (push) Successful in 16s
This commit is contained in:
1 file changed
+74
-20
@@ -33,28 +33,76 @@ Outputs: `labels` — the required entries that matched, comma-separated.
|
||||
An empty `labels` input, or the literal `disabled`, makes the check pass. Matching
|
||||
is case-insensitive. Anchor regexes (`^...$`) when you need an exact match.
|
||||
|
||||
### Gitea (org-wide, recommended)
|
||||
### Gitea
|
||||
|
||||
This repository is registered as a **scoped workflow source** for the `kosmos`
|
||||
org. `.gitea/scoped_workflows/required-labels.yaml` then runs on every org
|
||||
repository and, once marked **required**, gates merges.
|
||||
There are three ways to run the check on Gitea. All use the same action and the
|
||||
same Actions variables; pick whichever fits the set of repositories you want to
|
||||
gate.
|
||||
|
||||
The scoped workflow calls the action by absolute URL
|
||||
(`https://gitea.kosmos.org/kosmos/actions/required-labels@v1`). The `self:`
|
||||
prefix is documented as equivalent, but on this Gitea/runner combination a
|
||||
step-level `uses: self:...` failed before any job started, while the FQDN form
|
||||
works.
|
||||
#### 1. Org-wide (org-defined scoped workflow, required)
|
||||
|
||||
Rollout (one-off, UI-only — Gitea exposes no API for this):
|
||||
Register `kosmos/actions` once as a **scoped workflow source** (Org Settings →
|
||||
Actions → Scoped Workflows) and mark `.gitea/scoped_workflows/required-labels.yaml`
|
||||
**required** with the status-check pattern `kosmos/actions: Required labels / *`.
|
||||
|
||||
1. **Org Settings → Actions → Scoped Workflows** → add `kosmos/actions`.
|
||||
2. Leave it **not required** and soak: confirm the `Required labels` check runs
|
||||
on a test repository (e.g. `kosmos/test-one-two`).
|
||||
3. Mark `required-labels.yaml` **required** with status-check pattern
|
||||
`kosmos/actions: Required labels / *`. Note: a required check only gates
|
||||
target branches that have a branch-protection rule.
|
||||
- Gates every org repository that has a branch-protection rule (a required check
|
||||
is only enforced on protected branches).
|
||||
- Cannot be opted out of by repositories — that is the point.
|
||||
- One centrally maintained workflow definition.
|
||||
|
||||
Configuration is done with Actions variables (org default, per-repo override):
|
||||
Rollout (one-off, UI-only — Gitea exposes no API for this): add the source, soak
|
||||
with it **not required** (e.g. on `kosmos/test-one-two`), then mark it required.
|
||||
|
||||
#### 2. Selected repos (org-defined scoped workflow, required per repo)
|
||||
|
||||
The same registration, but leave the workflow **not required** and require its
|
||||
context per repository under **branch protection → status checks** with the
|
||||
pattern `kosmos/actions: Required labels / *`.
|
||||
|
||||
- Only the repositories you configure are gated.
|
||||
- The workflow still runs on every Actions-enabled repository and posts a green
|
||||
status where it is not enforced; a repository that does not want it can
|
||||
disable it from its Actions page.
|
||||
- Central definition, per-repository enforcement. (Don't both disable it and
|
||||
require its pattern — that blocks the repo.)
|
||||
|
||||
#### 3. Per-repo (repository workflow file)
|
||||
|
||||
Add `.gitea/workflows/required-labels.yaml` to each repository you want to gate
|
||||
and require its check in that repository's branch protection.
|
||||
|
||||
- No runs on other repositories at all, and the check name is repository-local.
|
||||
- One small file per gated repository.
|
||||
|
||||
```yaml
|
||||
name: Required labels
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, reopened, labeled, unlabeled, synchronize, edited, ready_for_review, converted_to_draft]
|
||||
jobs:
|
||||
required-labels:
|
||||
name: check
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: https://gitea.kosmos.org/kosmos/actions/required-labels@v1
|
||||
with:
|
||||
labels: ${{ vars.REQUIRED_PR_LABELS }}
|
||||
mode: ${{ vars.REQUIRED_PR_LABELS_MODE }}
|
||||
draft-passes: ${{ vars.REQUIRED_PR_LABELS_DRAFT_PASSES }}
|
||||
use-regex: "true"
|
||||
```
|
||||
|
||||
#### Check names
|
||||
|
||||
A scoped run posts `<source>: <workflow name> / <job> (<event>)`, e.g.
|
||||
`kosmos/actions: Required labels / check (pull_request)`; a repository-level run
|
||||
posts `<workflow name> / <job> (<event>)`, e.g.
|
||||
`Required labels / check (pull_request)`. Status-check patterns are globs, so
|
||||
`kosmos/actions: Required labels / *` matches whatever the job is named.
|
||||
|
||||
#### Configuration (all options)
|
||||
|
||||
Actions variables, org default with per-repository override:
|
||||
|
||||
- `REQUIRED_PR_LABELS` — the required labels/regexes. Org default:
|
||||
`^kredits(-[123]|/(small|medium|large))$`.
|
||||
@@ -68,6 +116,12 @@ The check is **fail-open**: an empty `REQUIRED_PR_LABELS` passes. The repo's own
|
||||
test workflow asserts the org variable is non-empty so an accidental wipe is
|
||||
noticed.
|
||||
|
||||
The examples call the action by absolute URL
|
||||
(`https://gitea.kosmos.org/kosmos/actions/required-labels@v1`). The `self:`
|
||||
prefix is documented as equivalent for scoped workflows, but on this Gitea/runner
|
||||
combination a step-level `uses: self:...` failed before any job started, while
|
||||
the FQDN form works.
|
||||
|
||||
### GitHub (per-repo)
|
||||
|
||||
```yaml
|
||||
@@ -77,7 +131,7 @@ on:
|
||||
types: [opened, reopened, labeled, unlabeled, synchronize, edited, ready_for_review, converted_to_draft]
|
||||
jobs:
|
||||
required-labels:
|
||||
name: Required labels
|
||||
name: check
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: 67P/actions/required-labels@v1
|
||||
@@ -87,8 +141,8 @@ jobs:
|
||||
mode: any
|
||||
```
|
||||
|
||||
Then require the `Required labels / required-labels` check in the repository's
|
||||
branch protection or ruleset.
|
||||
Then require the `Required labels / check` check in the repository's branch
|
||||
protection or ruleset.
|
||||
|
||||
## Development
|
||||
|
||||
|
||||
Reference in new issue
Block a user