diff --git a/README.md b/README.md index 89d400a..be7961c 100644 --- a/README.md +++ b/README.md @@ -304,6 +304,21 @@ repos: **Upgrading from 1.3.0:** a config with `default_webhook` and no `use_default_webhook` keeps working but connects nothing new. Add the key to each repo that should have the default, or run `sync-from-org` to mark the repos that already have it. That marks every repo holding the webhook, so delete any that shouldn't have it first. +### Labels + +`default_labels` are labels every repo in `repos` gets: for a label a process depends on, such as the one a CI workflow waits for. + +```yaml +default_labels: + - name: ok-to-test + color: "0e8a16" # six hex digits, no `#`; quote it so YAML reads a string + description: Run CI on this PR +``` + +- `sync` creates each label a repo lacks and corrects one whose color or description differs (an omitted description is none). It never deletes or renames a label, so a repo's other labels stay. Names match ignoring case, as on GitHub. Archived repos are skipped. `sync --dry-run` prints each label it would create or update. +- `diff` reads each listed repo's labels and lists what `sync` would write, exiting 1 if anything is; a repo whose labels can't be read is named. `sync-from-org` keeps the file's `default_labels`. +- Labels need a token that can write issues or pull requests (an App: `Issues` or `Pull requests`, write) for `sync`, and read them for `diff`. + ### Defaults and Merging You can provide a `defaults.config.yaml` file to specify org-wide or policy defaults. All fields are optional. The main config takes precedence over defaults. diff --git a/docs/changelog.md b/docs/changelog.md index 1fda8e3..b27547e 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file. - A required check can be pinned to the app that must post it: `{context: , app_id: }`. Only an `app_id` sets or changes a pin; a plain name keeps the ruleset's. `sync`, `diff` and `sync-from-org` compare and record pins. - `sync` keeps a `Require CI` ruleset's branch conditions and strictness when it rewrites it, instead of resetting them to the default branch and not strict. - New top-level `actions` block: the org's `default_workflow_permissions` and `can_approve_pull_request_reviews`. `sync` writes them, `sync-from-org` and `diff` read them back; without the block they're left alone. +- New top-level `default_labels`: labels every listed repo gets. `sync` creates a missing one and corrects its color and description, never deleting a label; `diff` lists what it would write; `sync-from-org` keeps them. ## [v1.3.2] - 2026-11-09 diff --git a/docs/usage.md b/docs/usage.md index f578719..6e279ca 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -96,6 +96,11 @@ default_webhook: # (object, optional) Webhook of repos with use events: - push +default_labels: # (list, optional) Labels every listed repo gets; sync never deletes one + - name: ok-to-test + color: "0e8a16" # (string) six hex digits, no "#" + description: Run CI on this PR # (string, optional) + default_branch_protections: # (list, optional) Default branch protection rules - pattern: main enforce_admins: true diff --git a/src/config.rs b/src/config.rs index 1814582..fca7218 100644 --- a/src/config.rs +++ b/src/config.rs @@ -205,6 +205,19 @@ impl WorkflowPermissions { } } +#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] +#[serde(deny_unknown_fields)] +/// An issue and pull request label every repo of the config gets. +pub struct Label { + /// The label's name. GitHub matches label names ignoring case. + pub name: String, + /// Six hex digits, without `#`. + pub color: String, + /// Empty: the label has no description. + #[serde(default, skip_serializing_if = "String::is_empty")] + pub description: String, +} + #[derive(Debug, Serialize, Deserialize, Clone)] // Added Clone #[serde(deny_unknown_fields)] /// @@ -281,6 +294,10 @@ pub struct Config { /// Default branch protection rules for all repositories (if not overridden). #[serde(default)] pub default_branch_protections: Vec, + /// Labels every repo in `repos` gets, archived ones aside. `sync` creates a missing one and corrects its color + /// and description; it never deletes a label, so a repo's other labels stay. + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub default_labels: Vec