Skip to content

Commit 937de7f

Browse files
authored
Fix docker run (devops-actions#67)
1 parent 0870dd7 commit 937de7f

File tree

5 files changed

+37
-41
lines changed

5 files changed

+37
-41
lines changed

.env

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
GITHUB_ACTOR=debugging
22
GITHUB_WORKSPACE=github_workspace
3-
GITHUB_OUTPUT=github_output_file
3+
GITHUB_OUTPUT=github_output_file
4+
DOCKER=false

Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
FROM ghcr.io/rajbos/actions-marketplace/powershell:7
22

3+
ENV DOCKER=true
4+
35
COPY /Src/PowerShell/*.ps1 /src/
46

57
ENTRYPOINT ["pwsh", "/src/entrypoint.ps1"]

Src/PowerShell/entrypoint.ps1

+17
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,23 @@ function main {
7676
Add-Content -Value "actions='$jsonObject'" -Path $env:GITHUB_OUTPUT
7777
}
7878

79+
if (Get-Module -ListAvailable -Name "powershell-yaml") {
80+
Write-Host "powershell-yaml Module exists"
81+
}
82+
else {
83+
Write-Host "powershell-yaml Module does not exist"
84+
Write-Host "Installing module for the yaml parsing"
85+
Install-Module -Name $moduleName -Force -Scope CurrentUser -AllowClobber
86+
}
87+
88+
try {
89+
Import-Module powershell-yaml -Force
90+
}
91+
catch {
92+
Write-Error "Error importing the powershell-yaml module"
93+
throw
94+
}
95+
7996
$currentLocation = Get-Location
8097
try {
8198
# always run in the correct location, where our scripts are located:

Src/PowerShell/generic.ps1

-36
This file was deleted.

Src/PowerShell/load-used-actions.ps1

+16-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ param (
99

1010
# pull in central calls library
1111
. $PSScriptRoot\github-calls.ps1
12-
. $PSScriptRoot\generic.ps1
1312

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

3736
# parse the workflow file and extract the actions used in it
38-
$parsedYaml = ConvertFrom-Yaml $workflow
37+
$parsedYaml =""
38+
try {
39+
$parsedYaml = ConvertFrom-Yaml $workflow
40+
}
41+
catch {
42+
Write-Warning "Error parsing the yaml from this workflow file: [$workflowFileName] in repo: [$repo]"
43+
Write-Warning "Workflow content:"
44+
Write-Warning $workflow
45+
Write-Warning ""
46+
Write-Warning "Error:"
47+
Write-Warning $_
48+
return
49+
}
3950

4051
# create hastable
4152
$actions = @()
@@ -112,11 +123,12 @@ function GetAllUsedActionsFromRepo {
112123
}
113124
}
114125
catch {
115-
Write-Warning "Error handling this workflow file:"
116-
Write-Host $workflowFile.Replace($PAT, "****") | ConvertFrom-Json -Depth 10
126+
Write-Warning "Error handling this workflow file [$($workflowFile.name)] in repo [$repo]:"
127+
Write-Host ($workflowFile | ConvertFrom-Json -Depth 10).Replace($PAT, "****")
117128
Write-Warning "----------------------------------"
118129
Write-Host "Error: [$_]"
119130
Write-Warning "----------------------------------"
131+
continue
120132
}
121133
}
122134

0 commit comments

Comments
 (0)