فینورا پرو - سامانه جامع حسابداری و صدور فاکتور

Fix idempotent milestone and label sync for roadmap issues

* Fix PowerShell issue metadata patch with idempotent JSON API * Rerun roadmap metadata workflow whenever its script changes

davoodmehraban89 committed Oct 14, 2026 at 08:43 UTC 0bab4e392e9c259116f4decbac1dd8567abb6acf
2 files changed +36 -4
.github/scripts/sync-roadmap.ps1
+35 -4
@@ -79,12 +79,43 @@ $assignments = @(
79 @{ N=19; Phase='A'; P='P0'; Area='operations'; Type='operations' }
80 @{ N=20; Phase='A'; P='P1'; Area='operations'; Type='operations' }
81 )
82 +# Resolve milestone IDs after create, so this also works on the first run.
83 +$milestonesNow = @(gh api ("repos/{0}/milestones?state=all&per_page=100" -f $repo) | ConvertFrom-Json)
84 +if ($LASTEXITCODE -ne 0) { throw 'Could not query milestones after setup' }
85 foreach ($item in $assignments) {
86 $phase = @($phaseDefs | Where-Object { $_.Code -eq $item.Phase })[0]
84 - $nameList = @('phase:'+$item.Phase,'priority:'+$item.P,'area:'+$item.Area,
85 - 'type:'+$item.Type,'status:planned')
86 - gh issue edit $item.N --repo $repo --milestone $phase.Title --add-label ($nameList -join ',') 1>$null
87 - if ($LASTEXITCODE -ne 0) { throw ('Failed to assign issue #' + $item.N) }
87 + $matches = @($milestonesNow | Where-Object { $_.title -eq $phase.Title })
88 + if ($matches.Count -ne 1) { throw ('Missing or duplicate milestone for ' + $item.Phase) }
89 + $issue = gh api ("repos/{0}/issues/{1}" -f $repo,$item.N) | ConvertFrom-Json
90 + if ($LASTEXITCODE -ne 0 -or -not $issue.number) {
91 + throw ('Failed to inspect issue #' + $item.N)
92 + }
93 + # Issue labels may already exist. Preserve unrelated labels and merge only
94 + # roadmap metadata rather than replacing the issue's current label set.
95 + $nameList = @(
96 + "phase:$($item.Phase)",
97 + "priority:$($item.P)",
98 + "area:$($item.Area)",
99 + "type:$($item.Type)",
100 + 'status:planned'
101 + )
102 + $existingNames = @($issue.labels | ForEach-Object { $_.name })
103 + $allNames = @($existingNames + $nameList | Sort-Object -Unique)
104 + $body = @{ milestone = [int]$matches[0].number; labels = $allNames } |
105 + ConvertTo-Json -Compress -Depth 5
106 + # PowerShell's native argument parsing may collapse comma-separated
107 + # --add-label arguments. Use the GitHub JSON API explicitly instead.
108 + $patched = $body | gh api -X PATCH ("repos/{0}/issues/{1}" -f $repo,$item.N) --input - |
109 + ConvertFrom-Json
110 + if ($LASTEXITCODE -ne 0 -or $patched.milestone.number -ne $matches[0].number) {
111 + throw ('Failed to assign issue #' + $item.N)
112 + }
113 + $patchedNames = @($patched.labels | ForEach-Object { $_.name })
114 + foreach ($needed in $nameList) {
115 + if ($patchedNames -notcontains $needed) {
116 + throw ('Missing assigned label ' + $needed + ' on issue #' + $item.N)
117 + }
118 + }
119 Write-Output ('ASSIGNED_ISSUE=' + $item.N + ' PHASE=' + $item.Phase)
120 }
121
.github/workflows/setup-roadmap-metadata.yml
+1
@@ -5,6 +5,7 @@ on:
5 branches: [main]
6 paths:
7 - '.github/workflows/setup-roadmap-metadata.yml'
8 + - '.github/scripts/sync-roadmap.ps1'
9 workflow_dispatch:
10
11 permissions: