From 23f93e2047540695ec2295dfc5c3a423b321e3c0 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 21 Jul 2025 23:15:53 +0200 Subject: [PATCH 01/13] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Remove=20GitHub?= =?UTF-8?q?=20App=20connection=20from=20Update-FontsData=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Update-FontsData.yml | 2 -- scripts/Update-FontsData.ps1 | 4 +--- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/Update-FontsData.yml b/.github/workflows/Update-FontsData.yml index 6d66ecd..9be1f04 100644 --- a/.github/workflows/Update-FontsData.yml +++ b/.github/workflows/Update-FontsData.yml @@ -20,6 +20,4 @@ jobs: - name: Update-FontsData uses: PSModule/GitHub-Script@v1 with: - ClientID: ${{ secrets.NERDFONTS_UPDATER_BOT_CLIENT_ID }} - PrivateKey: ${{ secrets.NERDFONTS_UPDATER_BOT_PRIVATE_KEY }} Script: scripts/Update-FontsData.ps1 diff --git a/scripts/Update-FontsData.ps1 b/scripts/Update-FontsData.ps1 index cba5f56..1d0b051 100644 --- a/scripts/Update-FontsData.ps1 +++ b/scripts/Update-FontsData.ps1 @@ -1,6 +1,4 @@ -Connect-GitHubApp -Organization PSModule -Default - -git checkout main +git checkout main git pull # 2. Retrieve the date-time to create a unique branch name. From ef205fb430d767392e138f841d12be7b47d0c7e9 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 21 Jul 2025 23:22:12 +0200 Subject: [PATCH 02/13] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Remove=20Agave?= =?UTF-8?q?=20font=20entry=20from=20FontsData.json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/FontsData.json | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/FontsData.json b/src/FontsData.json index 8eaba6d..2779819 100644 --- a/src/FontsData.json +++ b/src/FontsData.json @@ -11,10 +11,6 @@ "Name": "AdwaitaMono", "URL": "https://github.com/ryanoasis/nerd-fonts/releases/download/v3.4.0/AdwaitaMono.zip" }, - { - "Name": "Agave", - "URL": "https://github.com/ryanoasis/nerd-fonts/releases/download/v3.4.0/Agave.zip" - }, { "Name": "AnonymousPro", "URL": "https://github.com/ryanoasis/nerd-fonts/releases/download/v3.4.0/AnonymousPro.zip" From ec595ff7a399ea39f510b6d4ae20f785f675916b Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 21 Jul 2025 23:25:15 +0200 Subject: [PATCH 03/13] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Add=20permissio?= =?UTF-8?q?ns=20for=20pull-requests=20in=20Update-FontsData=20workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Update-FontsData.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/Update-FontsData.yml b/.github/workflows/Update-FontsData.yml index 9be1f04..61fe562 100644 --- a/.github/workflows/Update-FontsData.yml +++ b/.github/workflows/Update-FontsData.yml @@ -5,7 +5,8 @@ on: schedule: - cron: '0 0 * * *' -permissions: {} +permissions: + pull-requests: write jobs: Update-FontsData: From 64644c908c13ab1c9f60870f2be054a24ceb2f83 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 21 Jul 2025 23:51:54 +0200 Subject: [PATCH 04/13] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Refactor=20comm?= =?UTF-8?q?and=20execution=20to=20use=20Invoke-NativeCommand=20function=20?= =?UTF-8?q?in=20Update-FontsData=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/Update-FontsData.ps1 | 51 ++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/scripts/Update-FontsData.ps1 b/scripts/Update-FontsData.ps1 index 4735a1f..990cc97 100644 --- a/scripts/Update-FontsData.ps1 +++ b/scripts/Update-FontsData.ps1 @@ -1,12 +1,45 @@ -git checkout main -git pull +function Invoke-NativeCommand { + <# + .SYNOPSIS + Executes a native command with arguments. + #> + [Alias('Exec', 'Run')] + [CmdletBinding()] + param ( + # The command to execute + [Parameter(Mandatory, Position = 0)] + [string]$Command, + + # The arguments to pass to the command + [Parameter(ValueFromRemainingArguments)] + [string[]]$Arguments + ) + + Write-Debug "Command: $Command" + Write-Debug "Arguments: $($Arguments -join ', ')" + $fullCommand = "$Command $($Arguments -join ' ')" + + try { + Write-Verbose "Executing: $fullCommand" + & $Command @Arguments + if ($LASTEXITCODE -ne 0) { + $errorMessage = "Command failed with exit code $LASTEXITCODE`: $fullCommand" + Write-Error $errorMessage -ErrorId 'NativeCommandFailed' -Category OperationStopped -TargetObject $fullCommand + } + } catch { + throw + } +} + +Run git checkout main +Run git pull # 2. Retrieve the date-time to create a unique branch name. $timeStamp = Get-Date -Format 'yyyyMMdd-HHmmss' $branchName = "auto-font-update-$timeStamp" # 3. Create a new branch for the changes. -git checkout -b $branchName +Run git checkout -b $branchName # 4. Retrieve the latest font data from Nerd Fonts. $release = Get-GitHubRelease -Owner ryanoasis -Repository nerd-fonts @@ -30,15 +63,17 @@ $fonts | ConvertTo-Json | Set-Content -Path $filePath -Force # 6. Check if anything actually changed. # If git status --porcelain is empty, there are no new changes to commit. -$changes = git status --porcelain +$changes = Run git status --porcelain + + if (-not [string]::IsNullOrWhiteSpace($changes)) { # 7. Commit and push changes. - git add . - git commit -m "Update-FontsData via script on $timeStamp" - git push --set-upstream origin $branchName + Run git add . + Run git commit -m "Update-FontsData via script on $timeStamp" + Run git push --set-upstream origin $branchName # 8. Create a PR via GitHub CLI. - gh pr create ` + Run gh pr create ` --base main ` --head $branchName ` --title "Auto-Update: NerdFonts Data ($timeStamp)" ` From 2a5d206dd869ace714fa805a20ac9002469878a2 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 22 Jul 2025 07:27:19 +0200 Subject: [PATCH 05/13] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Add=20missing?= =?UTF-8?q?=20permissions=20for=20contents=20in=20Update-FontsData=20workf?= =?UTF-8?q?low?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Update-FontsData.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/Update-FontsData.yml b/.github/workflows/Update-FontsData.yml index 61fe562..85b20e5 100644 --- a/.github/workflows/Update-FontsData.yml +++ b/.github/workflows/Update-FontsData.yml @@ -6,6 +6,7 @@ on: - cron: '0 0 * * *' permissions: + contents: write pull-requests: write jobs: From 7de29bc7375a6172133c3800ab5bceb860562582 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 22 Jul 2025 07:40:16 +0200 Subject: [PATCH 06/13] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Ensure=20fetch-?= =?UTF-8?q?depth=20is=20set=20to=200=20in=20Update-FontsData=20workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Update-FontsData.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/Update-FontsData.yml b/.github/workflows/Update-FontsData.yml index 85b20e5..a0306dc 100644 --- a/.github/workflows/Update-FontsData.yml +++ b/.github/workflows/Update-FontsData.yml @@ -17,6 +17,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 with: + fetch-depth: 0 persist-credentials: false - name: Update-FontsData From dc61b44ed7b383004b6a33d89744e02e8e924c97 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 22 Jul 2025 07:43:05 +0200 Subject: [PATCH 07/13] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Add=20output=20?= =?UTF-8?q?formatting=20for=20font=20list=20in=20Update-FontsData=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/Update-FontsData.ps1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/Update-FontsData.ps1 b/scripts/Update-FontsData.ps1 index 990cc97..7ba38fc 100644 --- a/scripts/Update-FontsData.ps1 +++ b/scripts/Update-FontsData.ps1 @@ -53,6 +53,8 @@ foreach ($fontArchive in $fontAssets) { } } +$fonts | Sort-Object Name | Format-Table -AutoSize | Out-String + # 5. Write results to FontsData.json. $parentFolder = Split-Path -Path $PSScriptRoot -Parent $filePath = Join-Path -Path $parentFolder -ChildPath 'src\FontsData.json' From 01cda898fc9f7e51fc2cf7603de8856e99a568af Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 22 Jul 2025 09:21:08 +0200 Subject: [PATCH 08/13] Refactor to consistently use Invoke-NativeCommand for git operations in Update-FontsData script --- scripts/Update-FontsData.ps1 | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/scripts/Update-FontsData.ps1 b/scripts/Update-FontsData.ps1 index 7ba38fc..b02526b 100644 --- a/scripts/Update-FontsData.ps1 +++ b/scripts/Update-FontsData.ps1 @@ -31,17 +31,12 @@ } } -Run git checkout main -Run git pull - -# 2. Retrieve the date-time to create a unique branch name. +Invoke-NativeCommand git checkout main +Invoke-NativeCommand git pull $timeStamp = Get-Date -Format 'yyyyMMdd-HHmmss' $branchName = "auto-font-update-$timeStamp" +Invoke-NativeCommand git checkout -b $branchName -# 3. Create a new branch for the changes. -Run git checkout -b $branchName - -# 4. Retrieve the latest font data from Nerd Fonts. $release = Get-GitHubRelease -Owner ryanoasis -Repository nerd-fonts $fonts = @() $fontAssets = $release | Get-GitHubReleaseAsset | Where-Object { $_.Name -like '*.zip' } @@ -53,29 +48,22 @@ foreach ($fontArchive in $fontAssets) { } } -$fonts | Sort-Object Name | Format-Table -AutoSize | Out-String +LogGroup 'Latest Fonts' { + $fonts | Sort-Object Name | Format-Table -AutoSize | Out-String +} -# 5. Write results to FontsData.json. $parentFolder = Split-Path -Path $PSScriptRoot -Parent $filePath = Join-Path -Path $parentFolder -ChildPath 'src\FontsData.json' - -# Make sure file exists (or overwrite). $null = New-Item -Path $filePath -ItemType File -Force $fonts | ConvertTo-Json | Set-Content -Path $filePath -Force -# 6. Check if anything actually changed. -# If git status --porcelain is empty, there are no new changes to commit. -$changes = Run git status --porcelain - - +$changes = Invoke-NativeCommand git status --porcelain if (-not [string]::IsNullOrWhiteSpace($changes)) { - # 7. Commit and push changes. - Run git add . - Run git commit -m "Update-FontsData via script on $timeStamp" - Run git push --set-upstream origin $branchName + Invoke-NativeCommand git add . + Invoke-NativeCommand git commit -m "Update-FontsData via script on $timeStamp" + Invoke-NativeCommand git push --set-upstream origin $branchName - # 8. Create a PR via GitHub CLI. - Run gh pr create ` + Invoke-NativeCommand gh pr create ` --base main ` --head $branchName ` --title "Auto-Update: NerdFonts Data ($timeStamp)" ` From d07e880d1f81adbf53b9ff983572b475deec3ae1 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 22 Jul 2025 09:27:37 +0200 Subject: [PATCH 09/13] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Update=20fetch-?= =?UTF-8?q?depth=20to=201=20in=20Update-FontsData=20workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Update-FontsData.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Update-FontsData.yml b/.github/workflows/Update-FontsData.yml index a0306dc..0edec8b 100644 --- a/.github/workflows/Update-FontsData.yml +++ b/.github/workflows/Update-FontsData.yml @@ -17,7 +17,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 with: - fetch-depth: 0 + fetch-depth: 1 persist-credentials: false - name: Update-FontsData From bc63d0589484e8a17e247258994e1e84b2480b82 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 22 Jul 2025 09:45:39 +0200 Subject: [PATCH 10/13] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Update=20fetch-?= =?UTF-8?q?depth=20to=200=20in=20Update-FontsData=20workflow=20and=20enhan?= =?UTF-8?q?ce=20git=20operations=20in=20script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Update-FontsData.yml | 2 +- scripts/Update-FontsData.ps1 | 56 +++++++++++++++++++++----- 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/.github/workflows/Update-FontsData.yml b/.github/workflows/Update-FontsData.yml index 0edec8b..a0306dc 100644 --- a/.github/workflows/Update-FontsData.yml +++ b/.github/workflows/Update-FontsData.yml @@ -17,7 +17,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 with: - fetch-depth: 1 + fetch-depth: 0 persist-credentials: false - name: Update-FontsData diff --git a/scripts/Update-FontsData.ps1 b/scripts/Update-FontsData.ps1 index b02526b..83437e3 100644 --- a/scripts/Update-FontsData.ps1 +++ b/scripts/Update-FontsData.ps1 @@ -31,11 +31,36 @@ } } -Invoke-NativeCommand git checkout main -Invoke-NativeCommand git pull +# Get the current branch and default branch information +$currentBranch = (Invoke-NativeCommand git rev-parse --abbrev-ref HEAD).Trim() +$defaultBranch = (Invoke-NativeCommand git remote show origin | Select-String 'HEAD branch:' | ForEach-Object { $_.ToString().Split(':')[1].Trim() }) + +Write-Output "Current branch: $currentBranch" +Write-Output "Default branch: $defaultBranch" + +# Fetch latest changes from remote +Invoke-NativeCommand git fetch origin + +# Get the head branch (latest default branch) +Invoke-NativeCommand git checkout $defaultBranch +Invoke-NativeCommand git pull origin $defaultBranch + $timeStamp = Get-Date -Format 'yyyyMMdd-HHmmss' -$branchName = "auto-font-update-$timeStamp" -Invoke-NativeCommand git checkout -b $branchName + +# Determine target branch based on current context +if ($currentBranch -eq $defaultBranch) { + # Running on main/default branch - create new branch + $targetBranch = "auto-font-update-$timeStamp" + Write-Output "Running on default branch. Creating new branch: $targetBranch" + Invoke-NativeCommand git checkout -b $targetBranch +} else { + # Running on another branch (e.g., workflow_dispatch) - use current branch + $targetBranch = $currentBranch + Write-Output "Running on feature branch. Using existing branch: $targetBranch" + Invoke-NativeCommand git checkout $targetBranch + # Merge latest changes from default branch + Invoke-NativeCommand git merge origin/$defaultBranch +} $release = Get-GitHubRelease -Owner ryanoasis -Repository nerd-fonts $fonts = @() @@ -61,15 +86,24 @@ $changes = Invoke-NativeCommand git status --porcelain if (-not [string]::IsNullOrWhiteSpace($changes)) { Invoke-NativeCommand git add . Invoke-NativeCommand git commit -m "Update-FontsData via script on $timeStamp" - Invoke-NativeCommand git push --set-upstream origin $branchName - Invoke-NativeCommand gh pr create ` - --base main ` - --head $branchName ` - --title "Auto-Update: NerdFonts Data ($timeStamp)" ` - --body 'This PR updates FontsData.json with the latest NerdFonts metadata.' + # Push behavior depends on branch type + if ($targetBranch -eq $currentBranch -and $currentBranch -ne $defaultBranch) { + # Push to existing branch + Invoke-NativeCommand git push origin $targetBranch + Write-Output "Changes committed and pushed to existing branch: $targetBranch" + } else { + # Push new branch and create PR + Invoke-NativeCommand git push --set-upstream origin $targetBranch - Write-Output 'Changes detected and PR opened.' + Invoke-NativeCommand gh pr create ` + --base $defaultBranch ` + --head $targetBranch ` + --title "Auto-Update: NerdFonts Data ($timeStamp)" ` + --body 'This PR updates FontsData.json with the latest NerdFonts metadata.' + + Write-Output "Changes detected and PR opened for branch: $targetBranch" + } } else { Write-Output 'No changes to commit.' } From 1103fb5023ef89805eb007e0607d0f611d7ee27d Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions@users.noreply.github.com> Date: Tue, 22 Jul 2025 07:49:48 +0000 Subject: [PATCH 11/13] Update-FontsData via script on 20250722-074947 --- src/FontsData.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/FontsData.json b/src/FontsData.json index 2779819..8eaba6d 100644 --- a/src/FontsData.json +++ b/src/FontsData.json @@ -11,6 +11,10 @@ "Name": "AdwaitaMono", "URL": "https://github.com/ryanoasis/nerd-fonts/releases/download/v3.4.0/AdwaitaMono.zip" }, + { + "Name": "Agave", + "URL": "https://github.com/ryanoasis/nerd-fonts/releases/download/v3.4.0/Agave.zip" + }, { "Name": "AnonymousPro", "URL": "https://github.com/ryanoasis/nerd-fonts/releases/download/v3.4.0/AnonymousPro.zip" From 20159b854a5217269a8b3855e03e5dbf0a79467c Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 22 Jul 2025 10:03:12 +0200 Subject: [PATCH 12/13] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Enhance=20git?= =?UTF-8?q?=20operations=20in=20Update-FontsData=20script=20to=20display?= =?UTF-8?q?=20changes,=20commit=20details,=20and=20diffs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/Update-FontsData.ps1 | 19 +++++++++++++++++++ src/FontsData.json | 8 -------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/scripts/Update-FontsData.ps1 b/scripts/Update-FontsData.ps1 index 83437e3..981e66a 100644 --- a/scripts/Update-FontsData.ps1 +++ b/scripts/Update-FontsData.ps1 @@ -84,9 +84,28 @@ $fonts | ConvertTo-Json | Set-Content -Path $filePath -Force $changes = Invoke-NativeCommand git status --porcelain if (-not [string]::IsNullOrWhiteSpace($changes)) { + Write-Output 'Changes detected:' + Write-Output $changes + + # Show what will be committed + Write-Output 'Diff of changes to be committed:' + Invoke-NativeCommand git diff --cached HEAD -- src/FontsData.json 2>$null + if ($LASTEXITCODE -ne 0) { + # If --cached doesn't work (no staged changes), show unstaged diff + Invoke-NativeCommand git diff HEAD -- src/FontsData.json + } + Invoke-NativeCommand git add . Invoke-NativeCommand git commit -m "Update-FontsData via script on $timeStamp" + # Show the commit that was just created + Write-Output 'Commit created:' + Invoke-NativeCommand git log -1 --oneline + + # Show diff between HEAD and previous commit + Write-Output 'Changes in this commit:' + Invoke-NativeCommand git diff HEAD~1 HEAD -- src/FontsData.json + # Push behavior depends on branch type if ($targetBranch -eq $currentBranch -and $currentBranch -ne $defaultBranch) { # Push to existing branch diff --git a/src/FontsData.json b/src/FontsData.json index 8eaba6d..22b7f6c 100644 --- a/src/FontsData.json +++ b/src/FontsData.json @@ -7,14 +7,6 @@ "Name": "3270", "URL": "https://github.com/ryanoasis/nerd-fonts/releases/download/v3.4.0/3270.zip" }, - { - "Name": "AdwaitaMono", - "URL": "https://github.com/ryanoasis/nerd-fonts/releases/download/v3.4.0/AdwaitaMono.zip" - }, - { - "Name": "Agave", - "URL": "https://github.com/ryanoasis/nerd-fonts/releases/download/v3.4.0/Agave.zip" - }, { "Name": "AnonymousPro", "URL": "https://github.com/ryanoasis/nerd-fonts/releases/download/v3.4.0/AnonymousPro.zip" From 70d6aa8f55ef963a815d12e5cc54f506b5e4d5ce Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions@users.noreply.github.com> Date: Tue, 22 Jul 2025 08:09:57 +0000 Subject: [PATCH 13/13] Update-FontsData via script on 20250722-080956 --- src/FontsData.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/FontsData.json b/src/FontsData.json index 22b7f6c..8eaba6d 100644 --- a/src/FontsData.json +++ b/src/FontsData.json @@ -7,6 +7,14 @@ "Name": "3270", "URL": "https://github.com/ryanoasis/nerd-fonts/releases/download/v3.4.0/3270.zip" }, + { + "Name": "AdwaitaMono", + "URL": "https://github.com/ryanoasis/nerd-fonts/releases/download/v3.4.0/AdwaitaMono.zip" + }, + { + "Name": "Agave", + "URL": "https://github.com/ryanoasis/nerd-fonts/releases/download/v3.4.0/Agave.zip" + }, { "Name": "AnonymousPro", "URL": "https://github.com/ryanoasis/nerd-fonts/releases/download/v3.4.0/AnonymousPro.zip"