feat: add custom property value sync#72
Open
joshjohanning wants to merge 3 commits into
Open
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the action’s custom properties support from syncing org-level schema to also syncing repo-level custom property values across selected repositories within each organization (issue #51).
Changes:
- Adds
custom-property-values-file(plus per-orgcustom-property-values/custom-property-values-fileoverrides) and implements repository selection vianames,names-file, andquery. - Implements value syncing with schema validation, selection/conflict warnings, diff logging, and batched updates (30 repos/request).
- Updates docs, samples, tests, and bumps version to
1.13.0.
Show a summary per file
| File | Description |
|---|---|
src/index.js |
Adds parsing/normalization for custom property value rules and implements syncCustomPropertyValues() execution in run(). |
action.yml |
Introduces the new custom-property-values-file action input. |
README.md |
Documents custom property values syncing, selectors, precedence/override rules, and updates inputs list/permissions notes. |
__tests__/index.test.js |
Adds unit tests for values parsing/normalization and syncing behavior (diffing, conflicts, dry-run). |
sample-configuration/custom-property-values.yml |
Adds an example custom property values rules file. |
sample-configuration/orgs.yml |
Demonstrates per-org inline and file-based custom property values configuration. |
sample-configuration/teams/platform-repos.yml |
Adds a sample repo list file for names-file selectors. |
package.json |
Bumps version to 1.13.0. |
package-lock.json |
Updates lockfile version metadata to 1.13.0. |
badges/coverage.svg |
Updates the generated coverage badge. |
Copilot's findings
- Files reviewed: 8/10 changed files
- Comments generated: 4
- Preserve boolean values in normalizeCustomPropertyValue so true_false
custom properties are not coerced to strings before API writes
- Remove redundant GET /orgs/{org}/repos call; build repoNameMap from
currentEntries which already contains all org repositories
- Add true_false type validation in validateCustomPropertyValueRuleAgainstSchema
so non-boolean values (e.g. strings) are caught before hitting the API
- Update 'at least one setting' error message to mention both
organizations-file and custom-property-values-file config paths
- Add tests for boolean value preservation and true_false schema validation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Fix 1: fall back to GET /repos/{org}/{name} when a hard-selected repo
is not in the /properties/values response, avoiding false 'not found'
warnings for repos that have never had any property values set
- Fix 2: merge desired custom-properties schema into schemaMap in dry-run
mode so newly-defined properties don't cause false unknown-property
validation failures when schema and values are introduced together
- Fix 3: treat null/undefined and [] as equal in customPropertyValuesEqual
to prevent infinite re-patching when the API returns null for an empty
multi_select instead of []
- Fix 4: conflict warning now names both rule numbers and their values
to make debugging multi-rule conflicts easier
- Fix 5: cache /properties/values query results per-run so repeated rules
sharing the same query string don't re-paginate the whole org
- Bonus: aggregate all schema validation errors per rule before throwing
instead of stopping at the first invalid property
- Bonus: sort multi_select array values in batch grouping key so repos
with semantically identical values group into the same PATCH call
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment on lines
+362
to
+370
| if (Array.isArray(orgConfig['custom-property-values'])) { | ||
| for (const [index, rule] of orgConfig['custom-property-values'].entries()) { | ||
| if (typeof rule !== 'object' || rule === null) continue; | ||
| for (const key of Object.keys(rule)) { | ||
| if (!KNOWN_CUSTOM_PROPERTY_VALUE_RULE_KEYS.has(key)) { | ||
| core.warning( | ||
| `⚠️ Unknown custom property value rule key "${key}" found for rule ${index + 1} in organization "${orgName}". ` + | ||
| `This key may not exist or may have a typo.` | ||
| ); |
| } | ||
|
|
||
| const repoNameMap = new Map( | ||
| currentEntries.map(entry => [entry.repository_name.toLowerCase(), entry.repository_name]) |
Comment on lines
+4063
to
+4083
| if (schema.value_type === 'multi_select') { | ||
| if (!Array.isArray(property.value)) { | ||
| errors.push(`Custom property value ${context} property "${property.property_name}" must be an array`); | ||
| } else { | ||
| const err = getCustomPropertyAllowedValuesError(property, schema, context); | ||
| if (err) errors.push(err); | ||
| } | ||
| } else if (schema.value_type === 'true_false') { | ||
| if (typeof property.value !== 'boolean') { | ||
| errors.push( | ||
| `Custom property value ${context} property "${property.property_name}" must be a boolean (true or false)` | ||
| ); | ||
| } | ||
| } else { | ||
| if (Array.isArray(property.value)) { | ||
| errors.push(`Custom property value ${context} property "${property.property_name}" must not be an array`); | ||
| } else { | ||
| const err = getCustomPropertyAllowedValuesError(property, schema, context); | ||
| if (err) errors.push(err); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
custom-property-values-fileand per-orgcustom-property-valuessupport for repository custom property valuesValidation
npm run allFixes #51