Skip to content

Excavator

Excavator #2925

Workflow file for this run

on:
workflow_dispatch:
schedule:
# run every 4 hours
- cron: '20 */4 * * *'
name: Excavator
permissions:
contents: write
actions: write
jobs:
excavate:
name: Excavate
runs-on: windows-latest
steps:
- uses: actions/checkout@main
- name: Excavate
uses: ScoopInstaller/GithubActions@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SKIP_UPDATED: 1
- name: Trigger Winget for mapped manifest updates
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY: ${{ github.repository }}
REF_NAME: ${{ github.ref_name }}
START_SHA: ${{ github.sha }}
run: |
$remoteSha = (git ls-remote origin "refs/heads/$($env:REF_NAME)" | Select-Object -First 1) -split '\s+' | Select-Object -First 1
if (-not $remoteSha) {
Write-Host "No remote ref found."
exit 0
}
if ($remoteSha -eq $env:START_SHA) {
Write-Host "No new commit was pushed by Excavator."
exit 0
}
if (-not (Test-Path winget/package-map.json)) {
Write-Host "package map not found."
exit 0
}
$headers = @{
Authorization = "Bearer $env:GITHUB_TOKEN"
Accept = "application/vnd.github+json"
}
$mapped = @((Get-Content winget/package-map.json -Raw | ConvertFrom-Json).PSObject.Properties.Name)
$manifests = @(
(Invoke-RestMethod -Method Get -Headers $headers -Uri "https://api.github.com/repos/$($env:REPOSITORY)/compare/$($env:START_SHA)...$remoteSha").files |
Where-Object filename -Match '^bucket/[^/]+\.json$' |
ForEach-Object { [IO.Path]::GetFileNameWithoutExtension($_.filename) } |
Where-Object { $mapped -contains $_ } |
Sort-Object -Unique
)
if ($manifests.Count -eq 0) {
Write-Host "No mapped manifest updates detected."
exit 0
}
$dispatchInput = $manifests -join ','
Write-Host "Dispatching Winget workflow for manifests: $dispatchInput"
$payload = @{
ref = $env:REF_NAME
inputs = @{
manifests = $dispatchInput
}
} | ConvertTo-Json -Depth 10
Invoke-RestMethod -Method Post -Headers $headers -Uri "https://api.github.com/repos/$($env:REPOSITORY)/actions/workflows/winget.yml/dispatches" -ContentType "application/json" -Body $payload