Update Vendor #1163
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update Vendor | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| # At 13:37 UTC every day. | |
| - cron: '37 13 * * *' | |
| defaults: | |
| run: | |
| shell: pwsh | |
| permissions: | |
| contents: read | |
| jobs: | |
| vendor: | |
| runs-on: windows-latest | |
| continue-on-error: false | |
| timeout-minutes: 15 | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Summary - Workflow started | |
| shell: pwsh | |
| run: | | |
| echo "## 📦 Update Vendor - Workflow Summary" >> $env:GITHUB_STEP_SUMMARY | |
| echo "" >> $env:GITHUB_STEP_SUMMARY | |
| echo "Checking for vendor dependency updates..." >> $env:GITHUB_STEP_SUMMARY | |
| echo "" >> $env:GITHUB_STEP_SUMMARY | |
| - id: make-changes | |
| name: Checking for updates | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| $currentVersion = (Get-Content .\vendor\sources.json | ConvertFrom-Json) | |
| . .\scripts\update.ps1 -verbose | |
| Set-GHVariable -Name COUNT_UPDATED -Value $count | |
| $newVersion = (Get-Content .\vendor\sources.json | ConvertFrom-Json) | |
| $listUpdated = "" | |
| $updateMessage = "| Name | Old Version | New Version |`n| :--- | ---- | ---- |`n" | |
| foreach ($s in $newVersion) { | |
| $oldVersion = ($currentVersion | Where-Object {$_.name -eq $s.name}).version | |
| if ($s.version -ne $oldVersion) { | |
| $repoUrl = ($repoUrl = $s.Url.Replace("/archive/", "/releases/")).Substring(0, $repoUrl.IndexOf("/releases/")) + "/releases" | |
| $listUpdated += "$($s.name) v$($s.version), " | |
| $updateMessage += "| **[$($s.name)]($repoUrl)** | $oldVersion | **$($s.version)** |`n" | |
| } | |
| } | |
| if ($count -eq 0) { return } | |
| Set-GHVariable -Name LIST_UPDATED -Value $listUpdated.Trim(', ') | |
| echo "UPDATE_MESSAGE<<<EOF`n$updateMessage`n<EOF" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8 | |
| - name: Summary - Update check results | |
| shell: pwsh | |
| run: | | |
| $count = $env:COUNT_UPDATED | |
| if ($count -eq 0) { | |
| echo "### ✅ No Updates Available" >> $env:GITHUB_STEP_SUMMARY | |
| echo "" >> $env:GITHUB_STEP_SUMMARY | |
| echo "All vendor dependencies are up to date." >> $env:GITHUB_STEP_SUMMARY | |
| } else { | |
| $word = if ($count -eq 1) { 'dependency' } else { 'dependencies' } | |
| echo "### 🔄 Updates Found" >> $env:GITHUB_STEP_SUMMARY | |
| echo "" >> $env:GITHUB_STEP_SUMMARY | |
| echo "**$count** vendor $word updated:" >> $env:GITHUB_STEP_SUMMARY | |
| echo "" >> $env:GITHUB_STEP_SUMMARY | |
| echo "$env:UPDATE_MESSAGE" >> $env:GITHUB_STEP_SUMMARY | |
| echo "" >> $env:GITHUB_STEP_SUMMARY | |
| } | |
| - uses: peter-evans/create-pull-request@v7 | |
| if: env.COUNT_UPDATED > 0 | |
| with: | |
| title: 'Updates to `${{ env.COUNT_UPDATED }}` vendored dependencies' | |
| body: | | |
| ### Automatically updated `${{ env.COUNT_UPDATED }}` dependencies: | |
| ${{ env.UPDATE_MESSAGE }} | |
| --- | |
| Please verify and then **Merge** the pull request to update. | |
| commit-message: '⬆️ Update dependencies (${{ env.LIST_UPDATED }})' | |
| branch: update-vendor | |
| base: master | |
| - name: Summary - Pull request created | |
| if: env.COUNT_UPDATED > 0 | |
| shell: pwsh | |
| run: | | |
| echo "### 🎉 Pull Request Created" >> $env:GITHUB_STEP_SUMMARY | |
| echo "" >> $env:GITHUB_STEP_SUMMARY | |
| echo "A pull request has been created to update the vendor dependencies." >> $env:GITHUB_STEP_SUMMARY | |
| echo "" >> $env:GITHUB_STEP_SUMMARY | |
| echo "**Branch:** \`update-vendor\`" >> $env:GITHUB_STEP_SUMMARY | |
| echo "" >> $env:GITHUB_STEP_SUMMARY | |
| echo "**Updated dependencies:** $env:LIST_UPDATED" >> $env:GITHUB_STEP_SUMMARY | |
| echo "" >> $env:GITHUB_STEP_SUMMARY | |
| echo "> Please review and merge the pull request to apply the updates." >> $env:GITHUB_STEP_SUMMARY |