From b68b5ac8dca098c19d674e336cb40f6cf67153fe Mon Sep 17 00:00:00 2001 From: Rob Bos Date: Fri, 21 Jul 2023 09:11:13 +0000 Subject: [PATCH 01/21] Adding support for an output file instead of json string (which can become to big) --- .devcontainer/devcontainer.json | 40 +++++++++++++++++++++++++++++++++ .github/workflows/testing.yml | 17 +++++++++++++- Src/PowerShell/entrypoint.ps1 | 12 ++++++++-- action.yml | 2 ++ 4 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..5fb2dc2 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,40 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/powershell +{ + "name": "PowerShell", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/powershell:lts-debian-11", + "features": { + "ghcr.io/devcontainers/features/common-utils:2": { + "installZsh": "true", + "username": "vscode", + "upgradePackages": "false", + "nonFreePackages": "true" + }, + "ghcr.io/devcontainers/features/github-cli:1": {} + }, + + "postCreateCommand": "sudo chsh vscode -s \"$(which pwsh)\"", + + // Configure tool-specific properties. + "customizations": { + // Configure properties specific to VS Code. + "vscode": { + // Set *default* container specific settings.json values on container create. + "settings": { + "terminal.integrated.defaultProfile.linux": "pwsh" + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "ms-vscode.powershell" + ] + } + } + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index b7bc59b..3ed252a 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -35,7 +35,22 @@ jobs: Write-Host "Found [$($actions.Length)] actions" Set-Content -Value "Found [$($actions.Length)] actions" -Path $env:GITHUB_STEP_SUMMARY } - + + - shell: pwsh + run: | + # check the output file location to contain the expected content + Write-Host "Found actions file location here [${{ steps.load-actions.outputs.actions-file }}]" + $content = Get-Content -Path '${{ steps.load-actions.outputs.actions-file }}' + $actions = $content | ConvertFrom-Json + if ($actions.Length -le 0) { + Set-Content -Value "No actions found" -Path $env:GITHUB_STEP_SUMMARY + throw "No actions found" + } + else { + Write-Host "Found [$($actions.Length)] actions" + Set-Content -Value "Found [$($actions.Length)] actions" -Path $env:GITHUB_STEP_SUMMARY + } + - name: Upload result file as artefact uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 with: diff --git a/Src/PowerShell/entrypoint.ps1 b/Src/PowerShell/entrypoint.ps1 index 7738cd9..bd23a77 100644 --- a/Src/PowerShell/entrypoint.ps1 +++ b/Src/PowerShell/entrypoint.ps1 @@ -28,9 +28,17 @@ function main { # wite the file outside of the container so we can pick it up Write-Host "Found [$($actions.Count)] actions " #Write-Verbose $actions | ConvertTo-Json -Depth 10 - $jsonObject = ($actions | ConvertTo-Json -Depth 10 -Compress) - Set-Content -Value "actions='$jsonObject'" -Path $env:GITHUB_OUTPUT + $jsonObject = ($actions | ConvertTo-Json -Depth 10 -Compress) + Set-Content -Value "$jsonObject" -Path $filePath + + # store the json in a file and write the path to the output variable + $filePath = $env:GITHUB_WORKSPACE/used-actions.json + Set-Content -Value "actions-file='$filePath'" -Path $env:GITHUB_OUTPUT Write-Host "Stored actions in the actions output. Use $${{ steps..outputs.actions }} in next action to load the json" + Write-Host "Stored actions file in the actions output. Use $${{ steps..outputs.actions-file }} in next action to load the file" + + # write json content to output variable for backward compatibility (this used to be the only way to get the json) + Set-Content -Value "actions='$jsonObject'" -Path $env:GITHUB_OUTPUT } try { diff --git a/action.yml b/action.yml index d1e0970..17535d1 100644 --- a/action.yml +++ b/action.yml @@ -15,6 +15,8 @@ inputs: outputs: actions: description: 'List of all actions used in the organization' + actions-file: + description: 'Location of the file containing the list of all actions used in the organization' runs: using: 'docker' image: 'Dockerfile' From f550cf3cfc7002659d2e81c517031cf3047c536d Mon Sep 17 00:00:00 2001 From: Rob Bos Date: Fri, 21 Jul 2023 09:13:49 +0000 Subject: [PATCH 02/21] double check location setup --- Src/PowerShell/entrypoint.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Src/PowerShell/entrypoint.ps1 b/Src/PowerShell/entrypoint.ps1 index bd23a77..7170e9e 100644 --- a/Src/PowerShell/entrypoint.ps1 +++ b/Src/PowerShell/entrypoint.ps1 @@ -32,7 +32,8 @@ function main { Set-Content -Value "$jsonObject" -Path $filePath # store the json in a file and write the path to the output variable - $filePath = $env:GITHUB_WORKSPACE/used-actions.json + Write-Host "Location: $($env:GITHUB_WORKSPACE)" + $filePath = "$($env:GITHUB_WORKSPACE)/used-actions.json" Set-Content -Value "actions-file='$filePath'" -Path $env:GITHUB_OUTPUT Write-Host "Stored actions in the actions output. Use $${{ steps..outputs.actions }} in next action to load the json" Write-Host "Stored actions file in the actions output. Use $${{ steps..outputs.actions-file }} in next action to load the file" From c95d7024812f8b09c1a3d4d9bfcb42ac50f3d0ae Mon Sep 17 00:00:00 2001 From: Rob Bos Date: Fri, 21 Jul 2023 09:16:23 +0000 Subject: [PATCH 03/21] fix order --- Src/PowerShell/entrypoint.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Src/PowerShell/entrypoint.ps1 b/Src/PowerShell/entrypoint.ps1 index 7170e9e..6e08378 100644 --- a/Src/PowerShell/entrypoint.ps1 +++ b/Src/PowerShell/entrypoint.ps1 @@ -29,11 +29,11 @@ function main { Write-Host "Found [$($actions.Count)] actions " #Write-Verbose $actions | ConvertTo-Json -Depth 10 $jsonObject = ($actions | ConvertTo-Json -Depth 10 -Compress) - Set-Content -Value "$jsonObject" -Path $filePath - + # store the json in a file and write the path to the output variable Write-Host "Location: $($env:GITHUB_WORKSPACE)" $filePath = "$($env:GITHUB_WORKSPACE)/used-actions.json" + Set-Content -Value "$jsonObject" -Path $filePath Set-Content -Value "actions-file='$filePath'" -Path $env:GITHUB_OUTPUT Write-Host "Stored actions in the actions output. Use $${{ steps..outputs.actions }} in next action to load the json" Write-Host "Stored actions file in the actions output. Use $${{ steps..outputs.actions-file }} in next action to load the file" From e36140181c41f1c67256f90f557f7b70e62883ce Mon Sep 17 00:00:00 2001 From: Rob Bos Date: Fri, 21 Jul 2023 09:21:24 +0000 Subject: [PATCH 04/21] double check --- Src/PowerShell/entrypoint.ps1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Src/PowerShell/entrypoint.ps1 b/Src/PowerShell/entrypoint.ps1 index 6e08378..ecc3b11 100644 --- a/Src/PowerShell/entrypoint.ps1 +++ b/Src/PowerShell/entrypoint.ps1 @@ -31,8 +31,9 @@ function main { $jsonObject = ($actions | ConvertTo-Json -Depth 10 -Compress) # store the json in a file and write the path to the output variable - Write-Host "Location: $($env:GITHUB_WORKSPACE)" + Write-Host "Location: [$($env:GITHUB_WORKSPACE)]" $filePath = "$($env:GITHUB_WORKSPACE)/used-actions.json" + Write-Host "Output file path: [$filePath]" Set-Content -Value "$jsonObject" -Path $filePath Set-Content -Value "actions-file='$filePath'" -Path $env:GITHUB_OUTPUT Write-Host "Stored actions in the actions output. Use $${{ steps..outputs.actions }} in next action to load the json" @@ -40,6 +41,9 @@ function main { # write json content to output variable for backward compatibility (this used to be the only way to get the json) Set-Content -Value "actions='$jsonObject'" -Path $env:GITHUB_OUTPUT + Write-Host "File contents: " + Write-Host "-----------------" + cat $filePath } try { From c08ffdeac5426fe771d7426b54adae5dd6446514 Mon Sep 17 00:00:00 2001 From: Rob Bos Date: Fri, 21 Jul 2023 09:24:09 +0000 Subject: [PATCH 05/21] Check output content --- Src/PowerShell/entrypoint.ps1 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Src/PowerShell/entrypoint.ps1 b/Src/PowerShell/entrypoint.ps1 index ecc3b11..93f16ff 100644 --- a/Src/PowerShell/entrypoint.ps1 +++ b/Src/PowerShell/entrypoint.ps1 @@ -44,6 +44,9 @@ function main { Write-Host "File contents: " Write-Host "-----------------" cat $filePath + Write-Host "GITHUB_OUTPUT File contents: " + Write-Host "-----------------" + cat $env:GITHUB_OUTPUT } try { From eb374628804e37dab45a5f94904c947f87497db2 Mon Sep 17 00:00:00 2001 From: Rob Bos Date: Fri, 21 Jul 2023 09:28:15 +0000 Subject: [PATCH 06/21] Do not overwrite the output file --- Src/PowerShell/entrypoint.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Src/PowerShell/entrypoint.ps1 b/Src/PowerShell/entrypoint.ps1 index 93f16ff..93d8d22 100644 --- a/Src/PowerShell/entrypoint.ps1 +++ b/Src/PowerShell/entrypoint.ps1 @@ -40,7 +40,7 @@ function main { Write-Host "Stored actions file in the actions output. Use $${{ steps..outputs.actions-file }} in next action to load the file" # write json content to output variable for backward compatibility (this used to be the only way to get the json) - Set-Content -Value "actions='$jsonObject'" -Path $env:GITHUB_OUTPUT + Add-Content -Value "actions='$jsonObject'" -Path $env:GITHUB_OUTPUT Write-Host "File contents: " Write-Host "-----------------" cat $filePath From d1b5796a674ecd77df8caa2795310a0ac55316b7 Mon Sep 17 00:00:00 2001 From: Rob Bos Date: Fri, 21 Jul 2023 09:30:19 +0000 Subject: [PATCH 07/21] Change quotes? --- .github/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 3ed252a..2450a63 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -40,7 +40,7 @@ jobs: run: | # check the output file location to contain the expected content Write-Host "Found actions file location here [${{ steps.load-actions.outputs.actions-file }}]" - $content = Get-Content -Path '${{ steps.load-actions.outputs.actions-file }}' + $content = Get-Content -Path "${{ steps.load-actions.outputs.actions-file }}" $actions = $content | ConvertFrom-Json if ($actions.Length -le 0) { Set-Content -Value "No actions found" -Path $env:GITHUB_STEP_SUMMARY From 12a4df357ce7d6b97b6203611b147bb77db7b14a Mon Sep 17 00:00:00 2001 From: Rob Bos Date: Fri, 21 Jul 2023 09:32:03 +0000 Subject: [PATCH 08/21] remove extra qoutes in the outputs file --- Src/PowerShell/entrypoint.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Src/PowerShell/entrypoint.ps1 b/Src/PowerShell/entrypoint.ps1 index 93d8d22..3deb5ae 100644 --- a/Src/PowerShell/entrypoint.ps1 +++ b/Src/PowerShell/entrypoint.ps1 @@ -35,7 +35,7 @@ function main { $filePath = "$($env:GITHUB_WORKSPACE)/used-actions.json" Write-Host "Output file path: [$filePath]" Set-Content -Value "$jsonObject" -Path $filePath - Set-Content -Value "actions-file='$filePath'" -Path $env:GITHUB_OUTPUT + Set-Content -Value "actions-file=$filePath" -Path $env:GITHUB_OUTPUT Write-Host "Stored actions in the actions output. Use $${{ steps..outputs.actions }} in next action to load the json" Write-Host "Stored actions file in the actions output. Use $${{ steps..outputs.actions-file }} in next action to load the file" From e95907ef06d96d6386e318a28cd571ca87b79732 Mon Sep 17 00:00:00 2001 From: Rob Bos Date: Fri, 21 Jul 2023 09:35:48 +0000 Subject: [PATCH 09/21] test without quotes --- .github/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 2450a63..f5da1bc 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -40,7 +40,7 @@ jobs: run: | # check the output file location to contain the expected content Write-Host "Found actions file location here [${{ steps.load-actions.outputs.actions-file }}]" - $content = Get-Content -Path "${{ steps.load-actions.outputs.actions-file }}" + $content = Get-Content -Path ${{ steps.load-actions.outputs.actions-file }} $actions = $content | ConvertFrom-Json if ($actions.Length -le 0) { Set-Content -Value "No actions found" -Path $env:GITHUB_STEP_SUMMARY From 760708f95a7bb71724e0d67d04595bc9bc99806d Mon Sep 17 00:00:00 2001 From: Rob Bos Date: Fri, 21 Jul 2023 09:37:55 +0000 Subject: [PATCH 10/21] testing directory and content --- .github/workflows/testing.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index f5da1bc..c2630a9 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -35,6 +35,14 @@ jobs: Write-Host "Found [$($actions.Length)] actions" Set-Content -Value "Found [$($actions.Length)] actions" -Path $env:GITHUB_STEP_SUMMARY } + - shell: pwsh + run: | + # check the contents of the current dir + Write-Host "Where are we? [$pwd]" + + ForEach ($file in Get-ChildItem) { + Write-Host "- $($file.Name)" + } - shell: pwsh run: | From dacb0ed9cec7b63384aca2b39fb2b27a79748b5e Mon Sep 17 00:00:00 2001 From: Rob Bos Date: Fri, 21 Jul 2023 09:43:36 +0000 Subject: [PATCH 11/21] RUNNER_TEMP instad of GITHUB_WORKSPACE --- Src/PowerShell/entrypoint.ps1 | 7 ++----- Src/PowerShell/load-used-actions.ps1 | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Src/PowerShell/entrypoint.ps1 b/Src/PowerShell/entrypoint.ps1 index 3deb5ae..5580a83 100644 --- a/Src/PowerShell/entrypoint.ps1 +++ b/Src/PowerShell/entrypoint.ps1 @@ -31,8 +31,8 @@ function main { $jsonObject = ($actions | ConvertTo-Json -Depth 10 -Compress) # store the json in a file and write the path to the output variable - Write-Host "Location: [$($env:GITHUB_WORKSPACE)]" - $filePath = "$($env:GITHUB_WORKSPACE)/used-actions.json" + Write-Host "Location: [$($env:RUNNER_TEMP)]" + $filePath = "$($env:RUNNER_TEMP)/used-actions.json" Write-Host "Output file path: [$filePath]" Set-Content -Value "$jsonObject" -Path $filePath Set-Content -Value "actions-file=$filePath" -Path $env:GITHUB_OUTPUT @@ -41,9 +41,6 @@ function main { # write json content to output variable for backward compatibility (this used to be the only way to get the json) Add-Content -Value "actions='$jsonObject'" -Path $env:GITHUB_OUTPUT - Write-Host "File contents: " - Write-Host "-----------------" - cat $filePath Write-Host "GITHUB_OUTPUT File contents: " Write-Host "-----------------" cat $env:GITHUB_OUTPUT diff --git a/Src/PowerShell/load-used-actions.ps1 b/Src/PowerShell/load-used-actions.ps1 index 0628b36..2677418 100644 --- a/Src/PowerShell/load-used-actions.ps1 +++ b/Src/PowerShell/load-used-actions.ps1 @@ -190,7 +190,7 @@ function main() { $fileName = "summarized-actions.json" $jsonObject = ($summarizeActions | ConvertTo-Json -Depth 10) New-Item -Path $fileName -Value $jsonObject -Force | Out-Null - Write-Host "Stored the summarized usage info into this file: [$fileName]" + Write-Host "Stored the summarized usage info into this file: [$fileName] in this directory: [$PWD]" # upload the data into the marketplaceRepo #Write-Host "Found [$($actionsFound.actions.Length)] actions in use!" From 9b71122f0c6202f54c032f37604c1e1c094c54ad Mon Sep 17 00:00:00 2001 From: Rob Bos Date: Fri, 21 Jul 2023 09:48:54 +0000 Subject: [PATCH 12/21] strange --- .github/workflows/testing.yml | 2 +- Src/PowerShell/entrypoint.ps1 | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index c2630a9..2a345d3 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -48,7 +48,7 @@ jobs: run: | # check the output file location to contain the expected content Write-Host "Found actions file location here [${{ steps.load-actions.outputs.actions-file }}]" - $content = Get-Content -Path ${{ steps.load-actions.outputs.actions-file }} + $content = Get-Content -Path "${{ steps.load-actions.outputs.actions-file }}" $actions = $content | ConvertFrom-Json if ($actions.Length -le 0) { Set-Content -Value "No actions found" -Path $env:GITHUB_STEP_SUMMARY diff --git a/Src/PowerShell/entrypoint.ps1 b/Src/PowerShell/entrypoint.ps1 index 5580a83..48a1163 100644 --- a/Src/PowerShell/entrypoint.ps1 +++ b/Src/PowerShell/entrypoint.ps1 @@ -34,7 +34,12 @@ function main { Write-Host "Location: [$($env:RUNNER_TEMP)]" $filePath = "$($env:RUNNER_TEMP)/used-actions.json" Write-Host "Output file path: [$filePath]" - Set-Content -Value "$jsonObject" -Path $filePath + + ForEach ($file in Get-ChildItem "$($env:RUNNER_TEMP)") { + Write-Host "- $($file.Name)" + } + + Set-Content -Value "$jsonObject" -Path "$filePath" Set-Content -Value "actions-file=$filePath" -Path $env:GITHUB_OUTPUT Write-Host "Stored actions in the actions output. Use $${{ steps..outputs.actions }} in next action to load the json" Write-Host "Stored actions file in the actions output. Use $${{ steps..outputs.actions-file }} in next action to load the file" From 49eeba965c6548bd8bc57a5ade47e2e6bb7859b1 Mon Sep 17 00:00:00 2001 From: Rob Bos Date: Fri, 21 Jul 2023 09:54:02 +0000 Subject: [PATCH 13/21] skip the fancy paths then --- Src/PowerShell/entrypoint.ps1 | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Src/PowerShell/entrypoint.ps1 b/Src/PowerShell/entrypoint.ps1 index 48a1163..1552202 100644 --- a/Src/PowerShell/entrypoint.ps1 +++ b/Src/PowerShell/entrypoint.ps1 @@ -32,13 +32,9 @@ function main { # store the json in a file and write the path to the output variable Write-Host "Location: [$($env:RUNNER_TEMP)]" - $filePath = "$($env:RUNNER_TEMP)/used-actions.json" + $filePath = "used-actions.json" Write-Host "Output file path: [$filePath]" - ForEach ($file in Get-ChildItem "$($env:RUNNER_TEMP)") { - Write-Host "- $($file.Name)" - } - Set-Content -Value "$jsonObject" -Path "$filePath" Set-Content -Value "actions-file=$filePath" -Path $env:GITHUB_OUTPUT Write-Host "Stored actions in the actions output. Use $${{ steps..outputs.actions }} in next action to load the json" From 16cdc438173e15a1c643e088f395c98c93e85a7f Mon Sep 17 00:00:00 2001 From: Rob Bos Date: Fri, 21 Jul 2023 09:57:22 +0000 Subject: [PATCH 14/21] check current location --- .github/workflows/testing.yml | 2 +- Src/PowerShell/entrypoint.ps1 | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 2a345d3..e7fe5ba 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -47,7 +47,7 @@ jobs: - shell: pwsh run: | # check the output file location to contain the expected content - Write-Host "Found actions file location here [${{ steps.load-actions.outputs.actions-file }}]" + Write-Host "Got actions file location here [${{ steps.load-actions.outputs.actions-file }}]" $content = Get-Content -Path "${{ steps.load-actions.outputs.actions-file }}" $actions = $content | ConvertFrom-Json if ($actions.Length -le 0) { diff --git a/Src/PowerShell/entrypoint.ps1 b/Src/PowerShell/entrypoint.ps1 index 1552202..df18b1a 100644 --- a/Src/PowerShell/entrypoint.ps1 +++ b/Src/PowerShell/entrypoint.ps1 @@ -31,6 +31,7 @@ function main { $jsonObject = ($actions | ConvertTo-Json -Depth 10 -Compress) # store the json in a file and write the path to the output variable + Write-Host "Where are we? [$pwd]" Write-Host "Location: [$($env:RUNNER_TEMP)]" $filePath = "used-actions.json" Write-Host "Output file path: [$filePath]" From c6709959320e3617aba755559843ba0e56bab3ed Mon Sep 17 00:00:00 2001 From: Rob Bos Date: Fri, 21 Jul 2023 10:00:00 +0000 Subject: [PATCH 15/21] back to temp --- Src/PowerShell/entrypoint.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Src/PowerShell/entrypoint.ps1 b/Src/PowerShell/entrypoint.ps1 index df18b1a..f4a070b 100644 --- a/Src/PowerShell/entrypoint.ps1 +++ b/Src/PowerShell/entrypoint.ps1 @@ -33,7 +33,7 @@ function main { # store the json in a file and write the path to the output variable Write-Host "Where are we? [$pwd]" Write-Host "Location: [$($env:RUNNER_TEMP)]" - $filePath = "used-actions.json" + $filePath = "$($env:RUNNER_TEMP)used-actions.json" Write-Host "Output file path: [$filePath]" Set-Content -Value "$jsonObject" -Path "$filePath" From d6a0b187ed3365a18fa83ea4274adff11bde73c2 Mon Sep 17 00:00:00 2001 From: Rob Bos Date: Fri, 21 Jul 2023 10:06:49 +0000 Subject: [PATCH 16/21] fix path --- Src/PowerShell/entrypoint.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Src/PowerShell/entrypoint.ps1 b/Src/PowerShell/entrypoint.ps1 index f4a070b..51aab63 100644 --- a/Src/PowerShell/entrypoint.ps1 +++ b/Src/PowerShell/entrypoint.ps1 @@ -33,7 +33,7 @@ function main { # store the json in a file and write the path to the output variable Write-Host "Where are we? [$pwd]" Write-Host "Location: [$($env:RUNNER_TEMP)]" - $filePath = "$($env:RUNNER_TEMP)used-actions.json" + $filePath = "$($env:RUNNER_TEMP)/used-actions.json" Write-Host "Output file path: [$filePath]" Set-Content -Value "$jsonObject" -Path "$filePath" From 8f741db723fab40f961a94abefc967c17ec6795c Mon Sep 17 00:00:00 2001 From: Rob Bos Date: Fri, 21 Jul 2023 12:58:23 +0000 Subject: [PATCH 17/21] Show runner temp --- .github/workflows/testing.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index e7fe5ba..2758f49 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -38,11 +38,13 @@ jobs: - shell: pwsh run: | # check the contents of the current dir + echo $env:RUNNER_TEMP + cd $env:RUNNER_TEMP Write-Host "Where are we? [$pwd]" ForEach ($file in Get-ChildItem) { Write-Host "- $($file.Name)" - } + } - shell: pwsh run: | From f16ac2d5e6d678ee74fbe06e92959e391ca5e69a Mon Sep 17 00:00:00 2001 From: Rob Bos Date: Fri, 21 Jul 2023 13:01:53 +0000 Subject: [PATCH 18/21] try with workspace --- .github/workflows/testing.yml | 4 ++-- Src/PowerShell/entrypoint.ps1 | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 2758f49..9be25fd 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -38,8 +38,8 @@ jobs: - shell: pwsh run: | # check the contents of the current dir - echo $env:RUNNER_TEMP - cd $env:RUNNER_TEMP + echo $env:GITHUB_WORKSPACE + cd $env:GITHUB_WORKSPACE Write-Host "Where are we? [$pwd]" ForEach ($file in Get-ChildItem) { diff --git a/Src/PowerShell/entrypoint.ps1 b/Src/PowerShell/entrypoint.ps1 index 51aab63..d36037d 100644 --- a/Src/PowerShell/entrypoint.ps1 +++ b/Src/PowerShell/entrypoint.ps1 @@ -32,8 +32,8 @@ function main { # store the json in a file and write the path to the output variable Write-Host "Where are we? [$pwd]" - Write-Host "Location: [$($env:RUNNER_TEMP)]" - $filePath = "$($env:RUNNER_TEMP)/used-actions.json" + Write-Host "Location: [$($env:GITHUB_WORKSPACE)]" + $filePath = "$($env:GITHUB_WORKSPACE)/used-actions.json" Write-Host "Output file path: [$filePath]" Set-Content -Value "$jsonObject" -Path "$filePath" From 841f8cf457f05459ed0a90dc23ffccf69938f0be Mon Sep 17 00:00:00 2001 From: Rob Bos Date: Fri, 21 Jul 2023 13:04:11 +0000 Subject: [PATCH 19/21] cleaner --- Src/PowerShell/entrypoint.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Src/PowerShell/entrypoint.ps1 b/Src/PowerShell/entrypoint.ps1 index d36037d..901a1a1 100644 --- a/Src/PowerShell/entrypoint.ps1 +++ b/Src/PowerShell/entrypoint.ps1 @@ -33,11 +33,12 @@ function main { # store the json in a file and write the path to the output variable Write-Host "Where are we? [$pwd]" Write-Host "Location: [$($env:GITHUB_WORKSPACE)]" - $filePath = "$($env:GITHUB_WORKSPACE)/used-actions.json" + $fileName = "used-actions.json" + $filePath = "$($env:GITHUB_WORKSPACE)/$fileName" Write-Host "Output file path: [$filePath]" Set-Content -Value "$jsonObject" -Path "$filePath" - Set-Content -Value "actions-file=$filePath" -Path $env:GITHUB_OUTPUT + Set-Content -Value "actions-file=$fileName" -Path $env:GITHUB_OUTPUT Write-Host "Stored actions in the actions output. Use $${{ steps..outputs.actions }} in next action to load the json" Write-Host "Stored actions file in the actions output. Use $${{ steps..outputs.actions-file }} in next action to load the file" From 152d02fbe1d958a5a58dcfabf3db5510e8c053ae Mon Sep 17 00:00:00 2001 From: Rob Bos Date: Fri, 21 Jul 2023 13:07:18 +0000 Subject: [PATCH 20/21] cleanup --- .github/workflows/testing.yml | 35 +++++++++++++++++++++++------------ Src/PowerShell/entrypoint.ps1 | 11 ++--------- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 9be25fd..a6062d7 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -35,18 +35,9 @@ jobs: Write-Host "Found [$($actions.Length)] actions" Set-Content -Value "Found [$($actions.Length)] actions" -Path $env:GITHUB_STEP_SUMMARY } - - shell: pwsh - run: | - # check the contents of the current dir - echo $env:GITHUB_WORKSPACE - cd $env:GITHUB_WORKSPACE - Write-Host "Where are we? [$pwd]" - - ForEach ($file in Get-ChildItem) { - Write-Host "- $($file.Name)" - } - shell: pwsh + name: check the output file location to contain the expected content run: | # check the output file location to contain the expected content Write-Host "Got actions file location here [${{ steps.load-actions.outputs.actions-file }}]" @@ -65,7 +56,9 @@ jobs: uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 with: name: actions-${{ env.GITHUB_REPOSITORY_OWNER }} - path: actions.json + path: | + actions.json + used-actions.json load-all-used-actions-other-org: runs-on: ubuntu-latest @@ -96,9 +89,27 @@ jobs: Write-Host "Found [$($actions.Length)] actions" Set-Content -Value "Found [$($actions.Length)] actions" -Path $env:GITHUB_STEP_SUMMARY } + + - shell: pwsh + name: check the output file location to contain the expected content + run: | + # check the output file location to contain the expected content + Write-Host "Got actions file location here [${{ steps.load-actions.outputs.actions-file }}]" + $content = Get-Content -Path "${{ steps.load-actions.outputs.actions-file }}" + $actions = $content | ConvertFrom-Json + if ($actions.Length -le 0) { + Set-Content -Value "No actions found" -Path $env:GITHUB_STEP_SUMMARY + throw "No actions found" + } + else { + Write-Host "Found [$($actions.Length)] actions" + Set-Content -Value "Found [$($actions.Length)] actions" -Path $env:GITHUB_STEP_SUMMARY + } - name: Upload result file as artefact uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 with: name: actions-${{ env.organization }} - path: actions.json \ No newline at end of file + path: | + actions.json + used-actions.json \ No newline at end of file diff --git a/Src/PowerShell/entrypoint.ps1 b/Src/PowerShell/entrypoint.ps1 index 901a1a1..21e2c91 100644 --- a/Src/PowerShell/entrypoint.ps1 +++ b/Src/PowerShell/entrypoint.ps1 @@ -27,26 +27,19 @@ function main { # wite the file outside of the container so we can pick it up Write-Host "Found [$($actions.Count)] actions " - #Write-Verbose $actions | ConvertTo-Json -Depth 10 $jsonObject = ($actions | ConvertTo-Json -Depth 10 -Compress) - # store the json in a file and write the path to the output variable - Write-Host "Where are we? [$pwd]" - Write-Host "Location: [$($env:GITHUB_WORKSPACE)]" + # store the json in a file and write the path to the output variable $fileName = "used-actions.json" $filePath = "$($env:GITHUB_WORKSPACE)/$fileName" - Write-Host "Output file path: [$filePath]" Set-Content -Value "$jsonObject" -Path "$filePath" Set-Content -Value "actions-file=$fileName" -Path $env:GITHUB_OUTPUT Write-Host "Stored actions in the actions output. Use $${{ steps..outputs.actions }} in next action to load the json" - Write-Host "Stored actions file in the actions output. Use $${{ steps..outputs.actions-file }} in next action to load the file" + Write-Host "Stored actions file in the actions output. Use $${{ steps..outputs.actions-file }} in next action to load the file from the $$GITHUB_WORKSPACE folder" # write json content to output variable for backward compatibility (this used to be the only way to get the json) Add-Content -Value "actions='$jsonObject'" -Path $env:GITHUB_OUTPUT - Write-Host "GITHUB_OUTPUT File contents: " - Write-Host "-----------------" - cat $env:GITHUB_OUTPUT } try { From c6996f0465858c4dcaf6e9f5df4967137c36b87c Mon Sep 17 00:00:00 2001 From: Rob Bos Date: Fri, 21 Jul 2023 16:50:15 +0200 Subject: [PATCH 21/21] Update testing.yml --- .github/workflows/testing.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index a6062d7..4feac08 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -112,4 +112,4 @@ jobs: name: actions-${{ env.organization }} path: | actions.json - used-actions.json \ No newline at end of file + used-actions.json