Skip to content

Commit

Permalink
Adding support for an output file instead of json string (which can b…
Browse files Browse the repository at this point in the history
…ecome to big)
  • Loading branch information
rajbos authored Jul 21, 2023
1 parent 098d989 commit b68b5ac
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 3 deletions.
40 changes: 40 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -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"
}
17 changes: 16 additions & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 10 additions & 2 deletions Src/PowerShell/entrypoint.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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.<step id>.outputs.actions }} in next action to load the json"
Write-Host "Stored actions file in the actions output. Use $${{ steps.<step id>.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 {
Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit b68b5ac

Please sign in to comment.