Skip to content

oob-update

oob-update #360

Workflow file for this run

name: "OOB Update"
on:
repository_dispatch:
types:
- oob-update
jobs:
oob-update:
runs-on: ubuntu-latest
outputs:
agent-type: ${{ steps.validate-event.outputs.agent-type }}
agent-version: ${{ steps.validate-event.outputs.agent-version }}
steps:
- uses: actions/checkout@v4
- name: Validate Event
id: validate-event
run: |
$clientPayload = '${{ toJSON(github.event.client_payload) }}' | ConvertFrom-Json
[string] $agentType = $clientPayload.type
[string] $agentVersion = $clientPayload.version
[string] $manifestPath = "./src/$agentType/manifest.json"
if ($agentType -notmatch '^(nodejs|java|dotnet-core|dotnet-framework|php|python)$')
{
Write-Error "Failed to validate agent type."
exit 1
}
if (-not (Test-Path -Path $manifestPath))
{
Write-Error "$manifestPath does not exist."
exit 1
}
if ($agentVersion -notmatch '^\d+(\.\d+){2,3}$')
{
Write-Error "Failed to validate agent version."
exit 1
}
Write-Host "::set-output name=agent-type::$agentType"
Write-Host "::set-output name=agent-version::$agentVersion"
Write-Host "::set-output name=manifest-path::$manifestPath"
shell: pwsh
- name: Stage Changes
id: stage-changes
run: |
$agentVersion = '${{ steps.validate-event.outputs.agent-version }}'
$manifestPath = '${{ steps.validate-event.outputs.manifest-path }}'
$manifest = Get-Content -Path $manifestPath | ConvertFrom-Json
Write-Host "::set-output name=old-version::$($manifest.version)"
$manifest.version = $agentVersion
$manifest | ConvertTo-Json | Set-Content -Path $manifestPath -Encoding UTF8
shell: pwsh
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
id: create-pr
with:
add-paths: |
${{ steps.validate-event.outputs.manifest-path }}
commit-message: |
Upgraded '${{ steps.validate-event.outputs.agent-type }}' to '${{ steps.validate-event.outputs.agent-version }}'
branch: actions/oob-${{ steps.validate-event.outputs.agent-type }}-${{ steps.validate-event.outputs.agent-version }}
title: |
[OOB] Upgrades '${{ steps.validate-event.outputs.agent-type }}' to '${{ steps.validate-event.outputs.agent-version }}'
body: |
Automated OOB update requested by ${{ github.actor }}.
Agent: `${{ steps.validate-event.outputs.agent-type }}`
Version: `${{ steps.stage-changes.outputs.old-version }}` -> `${{ steps.validate-event.outputs.agent-version }}`
labels: |
oob-update
token: ${{ secrets.GH_PR_WRITE_PAT }}
- name: Enable Pull Request Automerge
if: steps.create-pr.outputs.pull-request-operation == 'created'
run: gh pr merge --rebase --auto "${{ steps.create-pr.outputs.pull-request-number }}"
env:
GH_TOKEN: ${{ secrets.GH_PR_WRITE_PAT }}