Skip to content

Commit ecc7884

Browse files
committed
Add fork sync step before manifest submission
Add a new step that synchronizes the user's fork of winget-pkgs with the upstream microsoft/winget-pkgs repository before submitting manifest updates. This ensures the fork is up-to-date and prevents merge conflicts.
1 parent 9b5b1aa commit ecc7884

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

.github/workflows/publish-winget.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,42 @@ jobs:
5858
run: |
5959
Invoke-WebRequest -Uri "https://aka.ms/wingetcreate/latest" -OutFile "wingetcreate.exe"
6060
61+
- name: Sync winget-pkgs fork
62+
shell: powershell
63+
env:
64+
WINGET_GITHUB_TOKEN: ${{ secrets.WINGET_GITHUB_TOKEN }}
65+
run: |
66+
$ErrorActionPreference = 'Stop'
67+
68+
if ([string]::IsNullOrWhiteSpace($env:WINGET_GITHUB_TOKEN)) {
69+
throw "Missing secret: WINGET_GITHUB_TOKEN"
70+
}
71+
72+
$env:GH_TOKEN = $env:WINGET_GITHUB_TOKEN
73+
$owner = (gh api user --jq .login).Trim()
74+
if ([string]::IsNullOrWhiteSpace($owner)) {
75+
throw "Unable to resolve GitHub login for WINGET_GITHUB_TOKEN"
76+
}
77+
78+
$upstreamDefaultBranch = (gh api repos/microsoft/winget-pkgs --jq .default_branch).Trim()
79+
if ([string]::IsNullOrWhiteSpace($upstreamDefaultBranch)) {
80+
throw "Unable to resolve microsoft/winget-pkgs default branch"
81+
}
82+
83+
$forkExists = $true
84+
try {
85+
gh api "repos/$owner/winget-pkgs" | Out-Null
86+
} catch {
87+
$forkExists = $false
88+
}
89+
90+
if (-not $forkExists) {
91+
gh api -X POST "repos/microsoft/winget-pkgs/forks" | Out-Null
92+
Start-Sleep -Seconds 5
93+
}
94+
95+
gh api -X POST "repos/$owner/winget-pkgs/merge-upstream" -f branch="$upstreamDefaultBranch" | Out-Null
96+
6197
- name: Submit WinGet manifest update
6298
shell: powershell
6399
env:

0 commit comments

Comments
 (0)