Update OPA executable version if necessary #695
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
| # Purpose: Update ScubaConfig and Support with the current version of OPA. | |
| name: Update OPA executable version if necessary | |
| # Run this workflow M-F at 2:11 a.m UTC 10:11 p.m Eastern Daylight Time | |
| on: | |
| schedule: | |
| - cron: "11 2 * * 1-5" | |
| workflow_dispatch: | |
| permissions: read-all | |
| jobs: | |
| update-opa-dependency: | |
| name: Update OPA Dependency | |
| runs-on: windows-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| actions: write | |
| defaults: | |
| run: | |
| shell: powershell | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Determine if update required | |
| id: determine-update-required | |
| continue-on-error: true | |
| shell: powershell | |
| run: | | |
| . utils/workflow/Update-Opa.ps1 | |
| $ReturnValues = Confirm-OpaUpdateRequirements -RepoPath . | |
| $Summary = $ReturnValues["Summary"] | |
| $LatestOPAVersion = $ReturnValues["LatestOPAVersion"] | |
| $OPAVersionBumpBranch = $ReturnValues["OPAVersionBumpBranch"] | |
| $UpdateRequired = $ReturnValues["UpdateRequired"] | |
| $CurrentOPAVersion = $ReturnValues["CurrentOPAVersion"] | |
| Write-Output $Summary | |
| Write-Output "LatestOPAVersion = $LatestOPAVersion" | |
| Write-Output "OPAVersionBumpBranch = $OPAVersionBumpBranch" | |
| Write-Output "UpdateRequired = $UpdateRequired" | |
| Write-Output "CurrentOPAVersion = $CurrentOPAVersion" | |
| echo latestopaversion=$LatestOPAVersion >> $env:GITHUB_OUTPUT | |
| echo opaversionbumpbranch=$OPAVersionBumpBranch >> $env:GITHUB_OUTPUT | |
| echo updaterequired=$UpdateRequired >> $env:GITHUB_OUTPUT | |
| echo currentopaversion=$CurrentOPAVersion >> $env:GITHUB_OUTPUT | |
| - name: Update OPA version | |
| if: steps.determine-update-required.outputs.updaterequired == 'true' | |
| run: | | |
| $LatestOpaVersion = "${{ steps.determine-update-required.outputs.latestopaversion }}" | |
| $CurrentOpaVersion = "${{ steps.determine-update-required.outputs.currentopaversion }}" | |
| . utils/workflow/Update-Opa.ps1 | |
| Update-OpaVersion ` | |
| -RepoPath . ` | |
| -CurrentOpaVersion $CurrentOpaVersion ` | |
| -LatestOpaVersion $LatestOPAVersion | |
| - name: Create new PR | |
| if: steps.determine-update-required.outputs.updaterequired == 'true' | |
| run: | | |
| $LatestOpaVersion = "${{ steps.determine-update-required.outputs.latestopaversion }}" | |
| $CurrentOpaVersion = "${{ steps.determine-update-required.outputs.currentopaversion }}" | |
| $OpaVersionBumpBranch = "${{ steps.determine-update-required.outputs.opaversionbumpbranch }}" | |
| . utils/workflow/Update-Opa.ps1 | |
| New-OpaUpdatePr ` | |
| -RepoPath . ` | |
| -CurrentOpaVersion $CurrentOpaVersion ` | |
| -LatestOpaVersion $LatestOPAVersion ` | |
| -OpaVersionBumpBranch $OpaVersionBumpBranch | |
| - name: Trigger smoke test workflow | |
| if: steps.determine-update-required.outputs.updaterequired == 'true' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| BRANCH_NAME: ${{ steps.determine-update-required.outputs.opaversionbumpbranch }} | |
| shell: pwsh | |
| run: | | |
| $headers = @{ | |
| Authorization = "Bearer $env:GITHUB_TOKEN" | |
| Accept = "application/vnd.github+json" | |
| } | |
| $body = @{ | |
| ref = "$env:BRANCH_NAME" | |
| } | ConvertTo-Json | |
| Invoke-RestMethod -Method Post ` | |
| -Uri "https://api.github.com/repos/${{ github.repository }}/actions/workflows/run_smoke_test.yaml/dispatches" ` | |
| -Headers $headers ` | |
| -Body $body |