Skip to content

Commit

Permalink
Update how AL-Go version is determined (#1186)
Browse files Browse the repository at this point in the history
Update how AL-Go version is determined. 

Since $ENV:GITHUB_REPOSITORY is the repository that runs the workflow,
AL-Go version will always be "Developer/Private" unless the workflow is
being run from a Microsoft-owned repo.
  • Loading branch information
aholstrup1 authored Sep 2, 2024
1 parent f6f62bb commit 67b4489
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Actions/WorkflowPostProcess/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ none
| shell | | The shell (powershell or pwsh) in which the PowerShell script in this action should run | powershell |
| telemetryScopeJson | | Telemetry scope generated during the workflow initialization | {} |
| currentJobContext | | The current job context | '' |
| actionsRepo | No | The repository of the action | github.action_repository |
| actionsRef | No | The ref of the action | github.action_ref |

## OUTPUT

Expand Down
10 changes: 6 additions & 4 deletions Actions/WorkflowPostProcess/WorkflowPostProcess.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
[string] $telemetryScopeJson = '',
[Parameter(HelpMessage = "The current job context", Mandatory = $false)]
[string] $currentJobContext = '',
[Parameter(HelpMessage = "The repository of the action", Mandatory = $false)]
[string] $actionsRepo,
[Parameter(HelpMessage = "The ref of the action", Mandatory = $false)]
[string] $actionsRef
)
Expand Down Expand Up @@ -42,10 +44,10 @@ function GetWorkflowConclusion($JobContext) {
return "Success"
}

function GetAlGoVersion($ActionRef) {
if ($ENV:GITHUB_REPOSITORY -eq "microsoft/AL-Go") {
function GetAlGoVersion($ActionsRepo, $ActionRef) {
if ($ActionsRepo -eq "microsoft/AL-Go") {
return "Preview"
} elseif($ENV:GITHUB_REPOSITORY -notlike "microsoft/*") {
} elseif($ActionsRepo -notlike "microsoft/*") {
return "Developer/Private"
} else {
return $ActionRef
Expand Down Expand Up @@ -102,7 +104,7 @@ function LogWorkflowEnd($TelemetryScopeJson, $JobContext, $AlGoVersion) {
Import-Module (Join-Path -Path $PSScriptRoot -ChildPath "..\TelemetryHelper.psm1" -Resolve)

try {
LogWorkflowEnd -TelemetryScopeJson $telemetryScopeJson -JobContext $currentJobContext -AlGoVersion (GetAlGoVersion -ActionRef $actionsRef)
LogWorkflowEnd -TelemetryScopeJson $telemetryScopeJson -JobContext $currentJobContext -AlGoVersion (GetAlGoVersion -ActionsRepo $actionsRepo -ActionRef $actionsRef)
} catch {
# Log the exception to telemetry but don't fail the action if gathering telemetry fails
Write-Host "::Warning::Unexpected error when running action. Error Message: $($_.Exception.Message.Replace("`r",'').Replace("`n",' ')), StackTrace: $($_.ScriptStackTrace.Replace("`r",'').Replace("`n",' <- '))";
Expand Down
7 changes: 6 additions & 1 deletion Actions/WorkflowPostProcess/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ inputs:
description: The current job context
required: false
default: ''
actionsRepo:
description: The repository of the action
required: false
default: ${{ github.action_repository }}
actionsRef:
description: The ref of the action
required: false
Expand All @@ -25,10 +29,11 @@ runs:
env:
_telemetryScopeJson: ${{ inputs.telemetryScopeJson }}
_currentJobContext: ${{ inputs.currentJobContext }}
_actionsRepo: ${{ inputs.actionsRepo }}
_actionsRef: ${{ inputs.actionsRef }}
run: |
${{ github.action_path }}/../Invoke-AlGoAction.ps1 -ActionName "WorkflowPostProcess" -Action {
${{ github.action_path }}/WorkflowPostProcess.ps1 -telemetryScopeJson $ENV:_telemetryScopeJson -currentJobContext $ENV:_currentJobContext -actionsRef $ENV:_actionsRef
${{ github.action_path }}/WorkflowPostProcess.ps1 -telemetryScopeJson $ENV:_telemetryScopeJson -currentJobContext $ENV:_currentJobContext -actionsRepo $ENV:_actionsRepo -actionsRef $ENV:_actionsRef
}
branding:
icon: terminal
Expand Down

0 comments on commit 67b4489

Please sign in to comment.