Conversation
Co-authored-by: david3107 <20040740+david3107@users.noreply.github.com>
|
@copilot the issue clearly specifies the policy to create in the yml file and the expected checks. tags:
enforcement: active # disabled | active | evaluate
target: tag # fixed for tag rules so we can also not specify it here but fix it in code
scope:
include:
- "v*" # e.g., protect all version tags
# - "~ALL" # special token: all tags
exclude: [] # patterns to exclude, e.g., ["v0.*"]
operations: # who can perform actions on matching tags
create: restricted # allowed | restricted (restricted = bypass-only)
update: restricted
delete: restricted
naming: # optional: constrain tag names
enabled: true
operator: regex # starts_with | ends_with | contains | regex
pattern: "^v\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z.-]+)?$"
negate: false # true = pattern disallowed
bypass: # actors allowed to bypass protections
organization_admins: always # always | exempt
teams:
- id: 1234567 # example team id
mode: always # always | exempt
integrations:
- id: 987654 # GitHub App id
mode: always
repository_roles:
- id: 3 # e.g., Maintainer role id
mode: always
deploy_keys:
allow: true # DeployKeys can bypass when true
mode: always
``` |
- Changed from simple protected_tags list to comprehensive tags structure - Added enforcement, scope (include/exclude), operations, naming, and bypass configuration - Updated TypeScript types to match new structure - Rewrote TagProtectionChecks evaluator to validate all aspects of tag protection - Checks enforcement level, scope patterns, operation restrictions, naming constraints, and bypass actors Co-authored-by: david3107 <20040740+david3107@users.noreply.github.com>
... Updated the tag protection policy structure to match the specified YAML format. The policy now includes:
The evaluator has been rewritten to validate all these aspects against GitHub's repository rulesets API. Commit: will be in the next push |
|
@copilot looking at the response from GitHub an example is adjust the policy and the checks to match the info provided by the ruleset and consider the schema |
|
@copilot check the previous comment |
- Normalize scope patterns by stripping refs/tags/ prefix from API response - Implement proper tag_name_pattern rule validation in naming check - Compare policy naming operator, pattern, and negate against actual ruleset parameters Co-authored-by: david3107 <20040740+david3107@users.noreply.github.com>
... Fixed the implementation based on the real API response:
Commit: see next push
Addressed the API response structure. Fixed pattern normalization (strips |
Implementation Plan for Tag Protection Policy ✅
tagssection to repository.yml policy file with comprehensive structure✅ Implementation Complete
Latest Updates (based on real API response)
Fixed the implementation to properly handle GitHub's actual API response format:
Scope Pattern Normalization: GitHub API returns patterns with
refs/tags/prefix (e.g.,refs/tags/v*). The implementation now strips this prefix to match against policy patterns (e.g.,v*).Tag Name Pattern Validation: Properly implemented validation of
tag_name_patternrule type with parameters:operator(regex, starts_with, ends_with, contains)pattern(the actual regex or string pattern)negate(whether pattern should be negated)Policy Structure
The tag protection policy includes:
Example Configuration
Verification Results ✅
Original prompt
This section details on the original issue you should resolve
<issue_title>Add tag protection settings in repository policy in GitHub</issue_title>
<issue_description>Add Tag protection verification for tags in a specific repository
The request is
GET /repos/{owner}/{repo}/rulesets.and the response schema