Skip to content

Commit

Permalink
Fix docker run (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
rajbos authored Sep 6, 2023
1 parent 0870dd7 commit 937de7f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 41 deletions.
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
GITHUB_ACTOR=debugging
GITHUB_WORKSPACE=github_workspace
GITHUB_OUTPUT=github_output_file
GITHUB_OUTPUT=github_output_file
DOCKER=false
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM ghcr.io/rajbos/actions-marketplace/powershell:7

ENV DOCKER=true

COPY /Src/PowerShell/*.ps1 /src/

ENTRYPOINT ["pwsh", "/src/entrypoint.ps1"]
17 changes: 17 additions & 0 deletions Src/PowerShell/entrypoint.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,23 @@ function main {
Add-Content -Value "actions='$jsonObject'" -Path $env:GITHUB_OUTPUT
}

if (Get-Module -ListAvailable -Name "powershell-yaml") {
Write-Host "powershell-yaml Module exists"
}
else {
Write-Host "powershell-yaml Module does not exist"
Write-Host "Installing module for the yaml parsing"
Install-Module -Name $moduleName -Force -Scope CurrentUser -AllowClobber
}

try {
Import-Module powershell-yaml -Force
}
catch {
Write-Error "Error importing the powershell-yaml module"
throw
}

$currentLocation = Get-Location
try {
# always run in the correct location, where our scripts are located:
Expand Down
36 changes: 0 additions & 36 deletions Src/PowerShell/generic.ps1

This file was deleted.

20 changes: 16 additions & 4 deletions Src/PowerShell/load-used-actions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ param (

# pull in central calls library
. $PSScriptRoot\github-calls.ps1
. $PSScriptRoot\generic.ps1

Write-Host "We're running with these parameters:"
Write-Host "- PAT.Length: [$($PAT.Length)]"
Expand All @@ -35,7 +34,19 @@ function GetActionsFromWorkflow {
)

# parse the workflow file and extract the actions used in it
$parsedYaml = ConvertFrom-Yaml $workflow
$parsedYaml =""
try {
$parsedYaml = ConvertFrom-Yaml $workflow
}
catch {
Write-Warning "Error parsing the yaml from this workflow file: [$workflowFileName] in repo: [$repo]"
Write-Warning "Workflow content:"
Write-Warning $workflow
Write-Warning ""
Write-Warning "Error:"
Write-Warning $_
return
}

# create hastable
$actions = @()
Expand Down Expand Up @@ -112,11 +123,12 @@ function GetAllUsedActionsFromRepo {
}
}
catch {
Write-Warning "Error handling this workflow file:"
Write-Host $workflowFile.Replace($PAT, "****") | ConvertFrom-Json -Depth 10
Write-Warning "Error handling this workflow file [$($workflowFile.name)] in repo [$repo]:"
Write-Host ($workflowFile | ConvertFrom-Json -Depth 10).Replace($PAT, "****")
Write-Warning "----------------------------------"
Write-Host "Error: [$_]"
Write-Warning "----------------------------------"
continue
}
}

Expand Down

0 comments on commit 937de7f

Please sign in to comment.