Choco Auto Update #355
This file contains 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: Choco Auto Update | |
on: | |
schedule: | |
- cron: "0 0 * * *" | |
workflow_dispatch: | |
defaults: | |
run: | |
shell: pwsh | |
jobs: | |
update: | |
name: Update ${{ matrix.package }} | |
runs-on: windows-latest | |
strategy: | |
max-parallel: 1 | |
matrix: | |
package: | |
- scaleway-cli | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Chocolatey Automatic Package Updater Module | |
run: Install-Module -Name AU -Force | |
- name: Install Powershell GetRedirectedURL | |
run: Install-Module -Name GetRedirectedURL -Force | |
- name: Run ${{ matrix.package }} update script | |
id: update | |
run: | | |
cd _auto\${{ matrix.package }} | |
$UpdateOutput = .\update.ps1 | |
$NupkgPath = (($UpdateOutput.Result | Where-Object {$_ -like '*.nupkg''*'}) -split "'")[1] | |
Write-Host "::set-output name=NupkgPath::$NupkgPath" | |
$UpdateStatus = if ($UpdateOutput.Result -match 'No new version found') {'No Update'} else {'Update Available'} | |
Write-Host "::set-output name=UpdateStatus::$UpdateStatus" | |
- name: Test ${{ matrix.package }} install | |
run: Test-Package -Install -Nu ${{ steps.update.outputs.NupkgPath }} | |
if: steps.update.outputs.UpdateStatus == 'Update Available' | |
- name: Publish to Chocolatey community feed | |
run: | | |
$Nupkg = '${{ steps.update.outputs.NupkgPath }}' | |
$ApiKey = '${{ secrets.CHOCOLATEY_KEY }}' | |
$ChocoServer = 'https://push.chocolatey.org/' | |
choco push $Nupkg --source $ChocoServer --key $ApiKey | |
if: steps.update.outputs.UpdateStatus == 'Update Available' | |
- name: Commit Updated nuspec | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: Apply Choco package update - ${{ matrix.package }} ${{ steps.update.outputs.newversion }} | |
file_pattern: "*.nuspec *.ps1" | |
if: steps.update.outputs.UpdateStatus == 'Update Available' | |
- uses: gautamkrishnar/keepalive-workflow@v2 | |
with: | |
use_api: true | |
if: steps.update.outputs.UpdateStatus != 'Update Available' |