From 35039ac396e72ced384b2e12720af3663a1184dc Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 17 Jan 2025 20:26:31 +0100 Subject: [PATCH 01/21] Add validation for input parameters in the configuration module --- .github/workflows/TestWorkflow.yml | 357 +++++++++++++++-------------- 1 file changed, 180 insertions(+), 177 deletions(-) diff --git a/.github/workflows/TestWorkflow.yml b/.github/workflows/TestWorkflow.yml index 93a6fbd..def1c8c 100644 --- a/.github/workflows/TestWorkflow.yml +++ b/.github/workflows/TestWorkflow.yml @@ -33,19 +33,19 @@ permissions: pull-requests: read jobs: - ActionTestBasic: - name: Basic - runs-on: ${{ inputs.runs-on }} - steps: - # Need to check out as part of the test, as its a local action - - name: Checkout repo - uses: actions/checkout@v4 + # ActionTestBasic: + # name: Basic + # runs-on: ${{ inputs.runs-on }} + # steps: + # # Need to check out as part of the test, as its a local action + # - name: Checkout repo + # uses: actions/checkout@v4 - - name: Action-Test - uses: ./ - with: - Debug: true - Verbose: true + # - name: Action-Test + # uses: ./ + # with: + # Debug: true + # Verbose: true ActionTestWithScript: name: WithScript @@ -61,194 +61,197 @@ jobs: Debug: true Verbose: true Script: | - LogGroup 'Get-GitHubZen' { - Get-GitHubZen + LogGroup 'EventInfo' { + Get-Content -Path $env:GITHUB_EVENT_PATH | ConvertFrom-Json | Format-List } - LogGroup 'Get-GitHubViewer' { - Get-GitHubViewer -Fields name, login, id, databaseID + LogGroup 'Object' { + [pscustomobject]@{ + Type = $env:GITHUB_EVENT_NAME + Action = $env:GITHUB_EVENT_PATH + } } - ActionTestCommands: - name: Commands + Outputs - runs-on: ${{ inputs.runs-on }} - steps: - # Need to check out as part of the test, as its a local action - - name: Checkout repo - uses: actions/checkout@v4 + # ActionTestCommands: + # name: Commands + Outputs + # runs-on: ${{ inputs.runs-on }} + # steps: + # # Need to check out as part of the test, as its a local action + # - name: Checkout repo + # uses: actions/checkout@v4 - - name: Action-Test - uses: ./ - id: test - with: - Debug: true - Verbose: true - Prerelease: true - ShowOutput: true - Script: | - LogGroup 'Get-GitHubZen' { - $cat = Get-GitHubOctocat - $zen = Get-GitHubZen - Set-GitHubEnvironmentVariable -Name 'OCTOCAT' -Value $cat - } + # - name: Action-Test + # uses: ./ + # id: test + # with: + # Debug: true + # Verbose: true + # Prerelease: true + # ShowOutput: true + # Script: | + # LogGroup 'Get-GitHubZen' { + # $cat = Get-GitHubOctocat + # $zen = Get-GitHubZen + # Set-GitHubEnvironmentVariable -Name 'OCTOCAT' -Value $cat + # } - LogGroup 'Set outputs - WISECAT' { - Set-GitHubOutput -Name 'WISECAT' -Value $cat - } + # LogGroup 'Set outputs - WISECAT' { + # Set-GitHubOutput -Name 'WISECAT' -Value $cat + # } - LogGroup 'Set outputs - Zen' { - Set-GitHubOutput -Name 'Zen' -Value $zen - } + # LogGroup 'Set outputs - Zen' { + # Set-GitHubOutput -Name 'Zen' -Value $zen + # } - LogGroup 'Set outputs - Context' { - Set-GitHubOutput -Name 'Context' -Value (Get-GitHubContext) - } + # LogGroup 'Set outputs - Context' { + # Set-GitHubOutput -Name 'Context' -Value (Get-GitHubContext) + # } - LogGroup 'Set outputs - GitConfig' { - Set-GitHubOutput -Name 'GitConfig' -Value (Get-GitHubGitConfig -Scope system) - } + # LogGroup 'Set outputs - GitConfig' { + # Set-GitHubOutput -Name 'GitConfig' -Value (Get-GitHubGitConfig -Scope system) + # } - LogGroup 'Set outputs - Zen2' { - Set-GitHubOutput -Name 'Zen2' -Value $zen - } + # LogGroup 'Set outputs - Zen2' { + # Set-GitHubOutput -Name 'Zen2' -Value $zen + # } - - name: Run-test - shell: pwsh - env: - result: ${{ steps.test.outputs.result }} - WISECAT: ${{ fromJson(steps.test.outputs.result).WISECAT }} - run: | - $result = $env:result | ConvertFrom-Json - Set-GitHubStepSummary -Summary $env:WISECAT - Write-GitHubNotice -Message $result.Zen -Title 'GitHub Zen' - Write-Host ($result.Zen2) - $result.Context | Format-List - $result.GitConfig | Format-List - - ActionTestWithoutToken: - name: WithoutToken - runs-on: ${{ inputs.runs-on }} - steps: - # Need to check out as part of the test, as its a local action - - name: Checkout repo - uses: actions/checkout@v4 + # - name: Run-test + # shell: pwsh + # env: + # result: ${{ steps.test.outputs.result }} + # WISECAT: ${{ fromJson(steps.test.outputs.result).WISECAT }} + # run: | + # $result = $env:result | ConvertFrom-Json + # Set-GitHubStepSummary -Summary $env:WISECAT + # Write-GitHubNotice -Message $result.Zen -Title 'GitHub Zen' + # Write-Host ($result.Zen2) + # $result.Context | Format-List + # $result.GitConfig | Format-List - - name: Action-Test - uses: ./ - with: - Token: '' - Script: | - LogGroup 'My group' { - 'This is a group' - } + # ActionTestWithoutToken: + # name: WithoutToken + # runs-on: ${{ inputs.runs-on }} + # steps: + # # Need to check out as part of the test, as its a local action + # - name: Checkout repo + # uses: actions/checkout@v4 - ActionTestWithPAT: - name: WithPAT - runs-on: ${{ inputs.runs-on }} - steps: - # Need to check out as part of the test, as its a local action - - name: Checkout repo - uses: actions/checkout@v4 + # - name: Action-Test + # uses: ./ + # with: + # Token: '' + # Script: | + # LogGroup 'My group' { + # 'This is a group' + # } - - name: Action-Test - uses: ./ - with: - Token: ${{ secrets.TEST_USER_PAT }} - Script: | - LogGroup 'Get-GitHubUser' { - Get-GitHubUser | Format-Table -AutoSize - } + # ActionTestWithPAT: + # name: WithPAT + # runs-on: ${{ inputs.runs-on }} + # steps: + # # Need to check out as part of the test, as its a local action + # - name: Checkout repo + # uses: actions/checkout@v4 - ActionTestWithUSERFGPAT: - name: WithUserFGPAT - runs-on: ${{ inputs.runs-on }} - steps: - # Need to check out as part of the test, as its a local action - - name: Checkout repo - uses: actions/checkout@v4 + # - name: Action-Test + # uses: ./ + # with: + # Token: ${{ secrets.TEST_USER_PAT }} + # Script: | + # LogGroup 'Get-GitHubUser' { + # Get-GitHubUser | Format-Table -AutoSize + # } - - name: Action-Test - uses: ./ - with: - Token: ${{ secrets.TEST_USER_USER_FG_PAT }} - Script: | - LogGroup 'Get-GitHubUser' { - Get-GitHubUser | Format-Table -AutoSize - } + # ActionTestWithUSERFGPAT: + # name: WithUserFGPAT + # runs-on: ${{ inputs.runs-on }} + # steps: + # # Need to check out as part of the test, as its a local action + # - name: Checkout repo + # uses: actions/checkout@v4 - ActionTestWithORGFGPAT: - name: WithOrgFGPAT - runs-on: ${{ inputs.runs-on }} - steps: - # Need to check out as part of the test, as its a local action - - name: Checkout repo - uses: actions/checkout@v4 + # - name: Action-Test + # uses: ./ + # with: + # Token: ${{ secrets.TEST_USER_USER_FG_PAT }} + # Script: | + # LogGroup 'Get-GitHubUser' { + # Get-GitHubUser | Format-Table -AutoSize + # } - - name: Action-Test - uses: ./ - with: - Token: ${{ secrets.TEST_USER_ORG_FG_PAT }} - Script: | - LogGroup 'Get-GitHubUser' { - Get-GitHubUser | Format-Table -AutoSize - } + # ActionTestWithORGFGPAT: + # name: WithOrgFGPAT + # runs-on: ${{ inputs.runs-on }} + # steps: + # # Need to check out as part of the test, as its a local action + # - name: Checkout repo + # uses: actions/checkout@v4 - ActionTestWithGitHubAppEnt: - name: GitHubAppEnt - runs-on: ${{ inputs.runs-on }} - steps: - # Need to check out as part of the test, as its a local action - - name: Checkout repo - uses: actions/checkout@v4 + # - name: Action-Test + # uses: ./ + # with: + # Token: ${{ secrets.TEST_USER_ORG_FG_PAT }} + # Script: | + # LogGroup 'Get-GitHubUser' { + # Get-GitHubUser | Format-Table -AutoSize + # } - - name: Action-Test - uses: ./ - with: - ClientID: ${{ secrets.TEST_APP_ENT_CLIENT_ID }} - PrivateKey: ${{ secrets.TEST_APP_ENT_PRIVATE_KEY }} - Script: | - LogGroup 'Get-GitHubApp' { - Get-GitHubApp | Format-Table -AutoSize - } + # ActionTestWithGitHubAppEnt: + # name: GitHubAppEnt + # runs-on: ${{ inputs.runs-on }} + # steps: + # # Need to check out as part of the test, as its a local action + # - name: Checkout repo + # uses: actions/checkout@v4 - LogGroup 'Get-GitHubAppInstallation' { - Get-GitHubAppInstallation | Format-Table -AutoSize - } + # - name: Action-Test + # uses: ./ + # with: + # ClientID: ${{ secrets.TEST_APP_ENT_CLIENT_ID }} + # PrivateKey: ${{ secrets.TEST_APP_ENT_PRIVATE_KEY }} + # Script: | + # LogGroup 'Get-GitHubApp' { + # Get-GitHubApp | Format-Table -AutoSize + # } - LogGroup 'Do something as an installation' { - Get-GithubAppInstallation | New-GitHubAppInstallationAccessToken | ForEach-Object { - Connect-GitHub -Token $_.token -Silent - Get-GitHubContext | Format-Table -AutoSize - Get-GitHubGitConfig | Format-Table -AutoSize - } - } + # LogGroup 'Get-GitHubAppInstallation' { + # Get-GitHubAppInstallation | Format-Table -AutoSize + # } - ActionTestWithGitHubAppOrg: - name: GitHubAppOrg - runs-on: ${{ inputs.runs-on }} - steps: - # Need to check out as part of the test, as its a local action - - name: Checkout repo - uses: actions/checkout@v4 + # LogGroup 'Do something as an installation' { + # Get-GithubAppInstallation | New-GitHubAppInstallationAccessToken | ForEach-Object { + # Connect-GitHub -Token $_.token -Silent + # Get-GitHubContext | Format-Table -AutoSize + # Get-GitHubGitConfig | Format-Table -AutoSize + # } + # } - - name: Action-Test - uses: ./ - with: - ClientID: ${{ secrets.TEST_APP_ORG_CLIENT_ID }} - PrivateKey: ${{ secrets.TEST_APP_ORG_PRIVATE_KEY }} - Script: | - LogGroup 'Get-GitHubApp' { - Get-GitHubApp | Format-Table -AutoSize - } + # ActionTestWithGitHubAppOrg: + # name: GitHubAppOrg + # runs-on: ${{ inputs.runs-on }} + # steps: + # # Need to check out as part of the test, as its a local action + # - name: Checkout repo + # uses: actions/checkout@v4 - LogGroup 'Get-GitHubAppInstallation' { - Get-GitHubAppInstallation | Format-Table -AutoSize - } + # - name: Action-Test + # uses: ./ + # with: + # ClientID: ${{ secrets.TEST_APP_ORG_CLIENT_ID }} + # PrivateKey: ${{ secrets.TEST_APP_ORG_PRIVATE_KEY }} + # Script: | + # LogGroup 'Get-GitHubApp' { + # Get-GitHubApp | Format-Table -AutoSize + # } - LogGroup 'Do something as an installation' { - Get-GithubAppInstallation | New-GitHubAppInstallationAccessToken | ForEach-Object { - Connect-GitHub -Token $_.token -Silent - Get-GitHubContext | Format-Table -AutoSize - Get-GitHubGitConfig | Format-Table -AutoSize - } - } + # LogGroup 'Get-GitHubAppInstallation' { + # Get-GitHubAppInstallation | Format-Table -AutoSize + # } + + # LogGroup 'Do something as an installation' { + # Get-GithubAppInstallation | New-GitHubAppInstallationAccessToken | ForEach-Object { + # Connect-GitHub -Token $_.token -Silent + # Get-GitHubContext | Format-Table -AutoSize + # Get-GitHubGitConfig | Format-Table -AutoSize + # } + # } From f735929d9f0881924f8943863e23388f17b02185 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 17 Jan 2025 20:34:00 +0100 Subject: [PATCH 02/21] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Enhance=20GitHu?= =?UTF-8?q?b=20event=20logging=20with=20detailed=20action=20and=20sender?= =?UTF-8?q?=20information?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/TestWorkflow.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/TestWorkflow.yml b/.github/workflows/TestWorkflow.yml index def1c8c..9c785bb 100644 --- a/.github/workflows/TestWorkflow.yml +++ b/.github/workflows/TestWorkflow.yml @@ -62,13 +62,18 @@ jobs: Verbose: true Script: | LogGroup 'EventInfo' { - Get-Content -Path $env:GITHUB_EVENT_PATH | ConvertFrom-Json | Format-List + $gitHubEvent = Get-Content -Path $env:GITHUB_EVENT_PATH | ConvertFrom-Json + $gitHubEvent | Format-List } LogGroup 'Object' { [pscustomobject]@{ Type = $env:GITHUB_EVENT_NAME - Action = $env:GITHUB_EVENT_PATH + Action = $gitHubEvent.action + Sender = $gitHubEvent.sender + Enterprise = $gitHubEvent.enterprise + Organization = $gitHubEvent.organization + Repository = $gitHubEvent.repository } } From 0b02c33e22774f4ed4a29e0ee8d8f43678bf29ee Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 17 Jan 2025 20:59:09 +0100 Subject: [PATCH 03/21] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Update=20workfl?= =?UTF-8?q?ows=20to=20trigger=20on=20workflow=5Fdispatch=20and=20enhance?= =?UTF-8?q?=20event=20logging?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Auto-Release.yml | 11 +----- .github/workflows/Linter.yml | 2 +- .github/workflows/TestWorkflow.yml | 54 +++++++++++++----------------- scripts/main.ps1 | 21 ++++++++++++ 4 files changed, 46 insertions(+), 42 deletions(-) diff --git a/.github/workflows/Auto-Release.yml b/.github/workflows/Auto-Release.yml index 1a580b8..ade68ff 100644 --- a/.github/workflows/Auto-Release.yml +++ b/.github/workflows/Auto-Release.yml @@ -2,16 +2,7 @@ name: Auto-Release run-name: "Auto-Release - [${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}] by @${{ github.actor }}" -on: - pull_request_target: - branches: - - main - types: - - closed - - opened - - reopened - - synchronize - - labeled +on: workflow_dispatch concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/Linter.yml b/.github/workflows/Linter.yml index 9477fd5..d3b814d 100644 --- a/.github/workflows/Linter.yml +++ b/.github/workflows/Linter.yml @@ -2,7 +2,7 @@ name: Linter run-name: "Linter - [${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}] by @${{ github.actor }}" -on: [pull_request] +on: workflow_dispatch concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/TestWorkflow.yml b/.github/workflows/TestWorkflow.yml index 9c785bb..d6665b7 100644 --- a/.github/workflows/TestWorkflow.yml +++ b/.github/workflows/TestWorkflow.yml @@ -33,8 +33,22 @@ permissions: pull-requests: read jobs: - # ActionTestBasic: - # name: Basic + ActionTestBasic: + name: Basic + runs-on: ${{ inputs.runs-on }} + steps: + # Need to check out as part of the test, as its a local action + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Action-Test + uses: ./ + # with: + # Debug: true + # Verbose: true + + # ActionTestWithScript: + # name: WithScript # runs-on: ${{ inputs.runs-on }} # steps: # # Need to check out as part of the test, as its a local action @@ -46,36 +60,14 @@ jobs: # with: # Debug: true # Verbose: true + # Script: | + # LogGroup 'Get-GitHubZen' { + # Get-GitHubZen + # } - ActionTestWithScript: - name: WithScript - runs-on: ${{ inputs.runs-on }} - steps: - # Need to check out as part of the test, as its a local action - - name: Checkout repo - uses: actions/checkout@v4 - - - name: Action-Test - uses: ./ - with: - Debug: true - Verbose: true - Script: | - LogGroup 'EventInfo' { - $gitHubEvent = Get-Content -Path $env:GITHUB_EVENT_PATH | ConvertFrom-Json - $gitHubEvent | Format-List - } - - LogGroup 'Object' { - [pscustomobject]@{ - Type = $env:GITHUB_EVENT_NAME - Action = $gitHubEvent.action - Sender = $gitHubEvent.sender - Enterprise = $gitHubEvent.enterprise - Organization = $gitHubEvent.organization - Repository = $gitHubEvent.repository - } - } + # LogGroup 'Get-GitHubViewer' { + # Get-GitHubViewer -Fields name, login, id, databaseID + # } # ActionTestCommands: # name: Commands + Outputs diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 5bce82b..a554889 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -96,6 +96,27 @@ process { } Write-Output '┗━━━━━━━━━━━━━━━━━━━━━━━━━━━┛' + + LogGroup 'EventInfo - JSON' { + $gitHubEventJson = Get-Content -Path $env:GITHUB_EVENT_PATH + Write-Output $gitHubEventJson + } + + LogGroup 'EventInfo - Object' { + $gitHubEvent = $gitHubEventJson | ConvertFrom-Json + $gitHubEvent | Format-List + } + + LogGroup 'Object' { + [pscustomobject]@{ + Type = $env:GITHUB_EVENT_NAME + Action = $gitHubEvent.action + Sender = $gitHubEvent.sender + Enterprise = $gitHubEvent.enterprise + Organization = $gitHubEvent.organization + Repository = $gitHubEvent.repository + } + } } catch { throw $_ } From 2aa22b65a7b9f16ca04988a8b0c9901598fa3f76 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 17 Jan 2025 21:00:19 +0100 Subject: [PATCH 04/21] Enhance output formatting for GitHub event details in main.ps1 --- scripts/main.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index a554889..41a3172 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -115,7 +115,7 @@ process { Enterprise = $gitHubEvent.enterprise Organization = $gitHubEvent.organization Repository = $gitHubEvent.repository - } + } | Format-List } } catch { throw $_ From 556abd79e9a88c07abbb4e15270a10524f0eb1b7 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 17 Jan 2025 21:07:10 +0100 Subject: [PATCH 05/21] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Refactor=20GitH?= =?UTF-8?q?ub=20event=20details=20to=20separate=20owner=20from=20repositor?= =?UTF-8?q?y=20information?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/main.ps1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 41a3172..4a8d359 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -114,7 +114,8 @@ process { Sender = $gitHubEvent.sender Enterprise = $gitHubEvent.enterprise Organization = $gitHubEvent.organization - Repository = $gitHubEvent.repository + Owner = $gitHubEvent.repository.owner + Repository = $gitHubEvent.repository | Select-Object -ExcludeProperty owner } | Format-List } } catch { From e87d16830e25d8f976ab6871b92f278b011330ad Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 17 Jan 2025 21:11:45 +0100 Subject: [PATCH 06/21] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Enhance=20GitHu?= =?UTF-8?q?b=20event=20logging=20by=20adding=20detailed=20information=20fo?= =?UTF-8?q?r=20sender,=20enterprise,=20organization,=20owner,=20and=20repo?= =?UTF-8?q?sitory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/main.ps1 | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 4a8d359..cb64340 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -107,6 +107,31 @@ process { $gitHubEvent | Format-List } + LogGroup 'EventInfo - Sender' { + $Sender = $gitHubEvent.sender + $Sender | Format-List + } + + LogGroup 'EventInfo - Enterprise' { + $Enterprise = $gitHubEvent.enterprise + $Enterprise | Format-List + } + + LogGroup 'EventInfo - Organization' { + $Organization = $gitHubEvent.organization + $Organization | Format-List + } + + LogGroup 'EventInfo - Owner' { + $Owner = $gitHubEvent.repository.owner + $Owner | Format-List + } + + LogGroup 'EventInfo - Repository' { + $Repository = $gitHubEvent.repository | Select-Object -ExcludeProperty owner + $Repository | Format-List + } + LogGroup 'Object' { [pscustomobject]@{ Type = $env:GITHUB_EVENT_NAME From 90009fe1a6660f519b5c276a448bc29c5870ef5b Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 17 Jan 2025 21:32:14 +0100 Subject: [PATCH 07/21] Enhance GitHub event logging by refining sender, enterprise, organization, owner, and repository details --- scripts/main.ps1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index cb64340..a852987 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -108,27 +108,27 @@ process { } LogGroup 'EventInfo - Sender' { - $Sender = $gitHubEvent.sender + $Sender = $gitHubEvent.sender | Select-Object -Property login, type, id, node_id, html_url $Sender | Format-List } LogGroup 'EventInfo - Enterprise' { - $Enterprise = $gitHubEvent.enterprise + $Enterprise = $gitHubEvent.enterprise | Select-Object -Property name, slug, id, node_id, html_url $Enterprise | Format-List } LogGroup 'EventInfo - Organization' { - $Organization = $gitHubEvent.organization + $Organization = $gitHubEvent.organization | Select-Object -Property login, id, node_id $Organization | Format-List } LogGroup 'EventInfo - Owner' { - $Owner = $gitHubEvent.repository.owner + $Owner = $gitHubEvent.repository.owner | Select-Object -Property login, type, id, node_id, html_url $Owner | Format-List } LogGroup 'EventInfo - Repository' { - $Repository = $gitHubEvent.repository | Select-Object -ExcludeProperty owner + $Repository = $gitHubEvent.repository | Select-Object -Property name, full_name, html_url, id, node_id, default_branch $Repository | Format-List } From 7dd8a576ee5de9dac6ac8cc11c52d8647fde07ea Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 17 Jan 2025 23:30:54 +0100 Subject: [PATCH 08/21] Refactor GitHub event logging to streamline data extraction and enhance output formatting --- scripts/main.ps1 | 71 ++++++++++++++++++++---------------------------- 1 file changed, 29 insertions(+), 42 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index a852987..b36c621 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -97,51 +97,38 @@ process { Write-Output '┗━━━━━━━━━━━━━━━━━━━━━━━━━━━┛' - LogGroup 'EventInfo - JSON' { + LogGroup 'EventInfo' { $gitHubEventJson = Get-Content -Path $env:GITHUB_EVENT_PATH - Write-Output $gitHubEventJson - } - - LogGroup 'EventInfo - Object' { $gitHubEvent = $gitHubEventJson | ConvertFrom-Json - $gitHubEvent | Format-List - } - - LogGroup 'EventInfo - Sender' { - $Sender = $gitHubEvent.sender | Select-Object -Property login, type, id, node_id, html_url - $Sender | Format-List - } - LogGroup 'EventInfo - Enterprise' { - $Enterprise = $gitHubEvent.enterprise | Select-Object -Property name, slug, id, node_id, html_url - $Enterprise | Format-List - } - - LogGroup 'EventInfo - Organization' { - $Organization = $gitHubEvent.organization | Select-Object -Property login, id, node_id - $Organization | Format-List - } - - LogGroup 'EventInfo - Owner' { - $Owner = $gitHubEvent.repository.owner | Select-Object -Property login, type, id, node_id, html_url - $Owner | Format-List - } - - LogGroup 'EventInfo - Repository' { - $Repository = $gitHubEvent.repository | Select-Object -Property name, full_name, html_url, id, node_id, default_branch - $Repository | Format-List - } - - LogGroup 'Object' { - [pscustomobject]@{ - Type = $env:GITHUB_EVENT_NAME - Action = $gitHubEvent.action - Sender = $gitHubEvent.sender - Enterprise = $gitHubEvent.enterprise - Organization = $gitHubEvent.organization - Owner = $gitHubEvent.repository.owner - Repository = $gitHubEvent.repository | Select-Object -ExcludeProperty owner - } | Format-List + $eventAction = $gitHubEvent.action + $eventSender = $gitHubEvent.sender | Select-Object -Property login, type, id, node_id, html_url + $eventEnterprise = $gitHubEvent.enterprise | Select-Object -Property name, slug, id, node_id, html_url + $eventOrganization = $gitHubEvent.organization | Select-Object -Property login, id, node_id + $eventOwner = $gitHubEvent.repository.owner | Select-Object -Property login, type, id, node_id, html_url + $eventRepository = $gitHubEvent.repository | Select-Object -Property name, full_name, html_url, id, node_id, default_branch + + $gitHubEvent = $gitHubEvent | Select-Object -ExcludeProperty action, sender, enterprise, organization, repository + $gitHubEvent | Add-Member -MemberType NoteProperty -Name Name -Value $env:GITHUB_EVENT_NAME -Force + if ($eventAction) { + $gitHubEvent | Add-Member -MemberType NoteProperty -Name Action -Value $eventAction -Force + } + if ($eventSender) { + $gitHubEvent | Add-Member -MemberType NoteProperty -Name Sender -Value $eventSender -Force + } + if ($eventEnterprise) { + $gitHubEvent | Add-Member -MemberType NoteProperty -Name Enterprise -Value $eventEnterprise -Force + } + if ($eventOrganization) { + $gitHubEvent | Add-Member -MemberType NoteProperty -Name Organization -Value $eventOrganization -Force + } + if ($eventOwner) { + $gitHubEvent | Add-Member -MemberType NoteProperty -Name Owner -Value $eventOwner -Force + } + if ($eventRepository) { + $gitHubEvent | Add-Member -MemberType NoteProperty -Name Repository -Value $eventRepository -Force + } + $gitHubEvent | Format-List } } catch { throw $_ From 9f21c79db15fbbf36d443941f16d590fe2be5b6e Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 18 Jan 2025 10:37:50 +0100 Subject: [PATCH 09/21] Refactor GitHub event logging to utilize Get-GithubWorkflowData for improved data handling --- .github/workflows/TestWorkflow.yml | 3 ++- scripts/main.ps1 | 32 +----------------------------- 2 files changed, 3 insertions(+), 32 deletions(-) diff --git a/.github/workflows/TestWorkflow.yml b/.github/workflows/TestWorkflow.yml index d6665b7..51be3b5 100644 --- a/.github/workflows/TestWorkflow.yml +++ b/.github/workflows/TestWorkflow.yml @@ -43,7 +43,8 @@ jobs: - name: Action-Test uses: ./ - # with: + with: + Prerelease: true # Debug: true # Verbose: true diff --git a/scripts/main.ps1 b/scripts/main.ps1 index b36c621..20364e1 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -98,37 +98,7 @@ process { Write-Output '┗━━━━━━━━━━━━━━━━━━━━━━━━━━━┛' LogGroup 'EventInfo' { - $gitHubEventJson = Get-Content -Path $env:GITHUB_EVENT_PATH - $gitHubEvent = $gitHubEventJson | ConvertFrom-Json - - $eventAction = $gitHubEvent.action - $eventSender = $gitHubEvent.sender | Select-Object -Property login, type, id, node_id, html_url - $eventEnterprise = $gitHubEvent.enterprise | Select-Object -Property name, slug, id, node_id, html_url - $eventOrganization = $gitHubEvent.organization | Select-Object -Property login, id, node_id - $eventOwner = $gitHubEvent.repository.owner | Select-Object -Property login, type, id, node_id, html_url - $eventRepository = $gitHubEvent.repository | Select-Object -Property name, full_name, html_url, id, node_id, default_branch - - $gitHubEvent = $gitHubEvent | Select-Object -ExcludeProperty action, sender, enterprise, organization, repository - $gitHubEvent | Add-Member -MemberType NoteProperty -Name Name -Value $env:GITHUB_EVENT_NAME -Force - if ($eventAction) { - $gitHubEvent | Add-Member -MemberType NoteProperty -Name Action -Value $eventAction -Force - } - if ($eventSender) { - $gitHubEvent | Add-Member -MemberType NoteProperty -Name Sender -Value $eventSender -Force - } - if ($eventEnterprise) { - $gitHubEvent | Add-Member -MemberType NoteProperty -Name Enterprise -Value $eventEnterprise -Force - } - if ($eventOrganization) { - $gitHubEvent | Add-Member -MemberType NoteProperty -Name Organization -Value $eventOrganization -Force - } - if ($eventOwner) { - $gitHubEvent | Add-Member -MemberType NoteProperty -Name Owner -Value $eventOwner -Force - } - if ($eventRepository) { - $gitHubEvent | Add-Member -MemberType NoteProperty -Name Repository -Value $eventRepository -Force - } - $gitHubEvent | Format-List + Get-GithubWorkflowData | Format-List } } catch { throw $_ From 92d4578ddcc73fa09f7d99ecd6bb4dd4194968da Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 18 Jan 2025 11:32:25 +0100 Subject: [PATCH 10/21] Refactor event logging to log GitHub event data separately for improved clarity --- scripts/main.ps1 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 20364e1..30a0b45 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -95,11 +95,12 @@ process { Get-GitHubConfig | Format-List } + LogGroup ' - Event Info' { + Get-GithubEventData | Format-List + } + Write-Output '┗━━━━━━━━━━━━━━━━━━━━━━━━━━━┛' - LogGroup 'EventInfo' { - Get-GithubWorkflowData | Format-List - } } catch { throw $_ } From e06685fdff5251fe01470f98c962e05cfe03c93b Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 18 Jan 2025 11:36:49 +0100 Subject: [PATCH 11/21] Refactor GitHub event logging to use cached event data for improved performance --- scripts/main.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 30a0b45..131980a 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -96,7 +96,7 @@ process { } LogGroup ' - Event Info' { - Get-GithubEventData | Format-List + $GithubEvent | Format-List } Write-Output '┗━━━━━━━━━━━━━━━━━━━━━━━━━━━┛' From 99dabc44bb448f5e509ae94181c4a9c171f7133e Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 18 Jan 2025 11:59:00 +0100 Subject: [PATCH 12/21] Refactor GitHub event logging to use Get-GithubEventData for improved data retrieval --- scripts/main.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 131980a..30a0b45 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -96,7 +96,7 @@ process { } LogGroup ' - Event Info' { - $GithubEvent | Format-List + Get-GithubEventData | Format-List } Write-Output '┗━━━━━━━━━━━━━━━━━━━━━━━━━━━┛' From 41ab65542fedd8dc612e9043ecbde28b68dd7a38 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 18 Jan 2025 12:32:09 +0100 Subject: [PATCH 13/21] Add logging for GitHub runner information to enhance visibility --- scripts/main.ps1 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 30a0b45..fe8b9ce 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -99,6 +99,21 @@ process { Get-GithubEventData | Format-List } + LogGroup ' - Runner Info' { + [pscustomobject]@{ + Name = $env:RUNNER_NAME + OS = $env:RUNNER_OS + Arch = $env:RUNNER_ARCH + Environment = $env:RUNNER_ENVIRONMENT + Temp = $env:RUNNER_TEMP + $Perflog = $env:RUNNER_PERFLOG + $ToolCache = $env:RUNNER_TOOL_CACHE + $TrackingID = $env:RUNNER_TRACKING_ID + Workspace = $env:RUNNER_WORKSPACE + Processors = [System.Environment]::ProcessorCount + } | Format-List + } + Write-Output '┗━━━━━━━━━━━━━━━━━━━━━━━━━━━┛' } catch { From 8ba5708253756190c401240032dd30742c62b35c Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 18 Jan 2025 12:34:05 +0100 Subject: [PATCH 14/21] Refactor environment variable logging for improved readability --- scripts/main.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index fe8b9ce..84f66b2 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -106,9 +106,9 @@ process { Arch = $env:RUNNER_ARCH Environment = $env:RUNNER_ENVIRONMENT Temp = $env:RUNNER_TEMP - $Perflog = $env:RUNNER_PERFLOG - $ToolCache = $env:RUNNER_TOOL_CACHE - $TrackingID = $env:RUNNER_TRACKING_ID + Perflog = $env:RUNNER_PERFLOG + ToolCache = $env:RUNNER_TOOL_CACHE + TrackingID = $env:RUNNER_TRACKING_ID Workspace = $env:RUNNER_WORKSPACE Processors = [System.Environment]::ProcessorCount } | Format-List From 980eff1090209002c2e47b3a9ddcdaa84c101706 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 18 Jan 2025 12:43:07 +0100 Subject: [PATCH 15/21] Enhance environment logging by creating a custom object for static properties --- scripts/main.ps1 | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 84f66b2..f0fe0f5 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -106,12 +106,32 @@ process { Arch = $env:RUNNER_ARCH Environment = $env:RUNNER_ENVIRONMENT Temp = $env:RUNNER_TEMP - Perflog = $env:RUNNER_PERFLOG - ToolCache = $env:RUNNER_TOOL_CACHE - TrackingID = $env:RUNNER_TRACKING_ID + Perflog = $env:RUNNER_PERFLOG + ToolCache = $env:RUNNER_TOOL_CACHE + TrackingID = $env:RUNNER_TRACKING_ID Workspace = $env:RUNNER_WORKSPACE Processors = [System.Environment]::ProcessorCount } | Format-List + + # Create an empty hashtable to store property name/value pairs. + $props = @{} + + # Enumerate each static property on [System.Environment]. + [System.Environment] | + Get-Member -Static -MemberType Property | + ForEach-Object { + # Store the value of each static property in the hashtable, + # keyed by the property name. + $props[$_.Name] = [System.Environment]::$($_.Name) + } + + # Cast the hashtable to a PSCustomObject so you get a single object + # with all property/value pairs. + $EnvironmentObject = [PSCustomObject]$props + + # Display the custom object. + $EnvironmentObject | Format-List + } Write-Output '┗━━━━━━━━━━━━━━━━━━━━━━━━━━━┛' From 982038e42895ff713eccdc9ae6e4e46b3901a2e1 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 18 Jan 2025 12:46:59 +0100 Subject: [PATCH 16/21] Remove unused static property logging in main.ps1 and read GitHub state directly --- scripts/main.ps1 | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index f0fe0f5..537bed9 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -112,26 +112,7 @@ process { Workspace = $env:RUNNER_WORKSPACE Processors = [System.Environment]::ProcessorCount } | Format-List - - # Create an empty hashtable to store property name/value pairs. - $props = @{} - - # Enumerate each static property on [System.Environment]. - [System.Environment] | - Get-Member -Static -MemberType Property | - ForEach-Object { - # Store the value of each static property in the hashtable, - # keyed by the property name. - $props[$_.Name] = [System.Environment]::$($_.Name) - } - - # Cast the hashtable to a PSCustomObject so you get a single object - # with all property/value pairs. - $EnvironmentObject = [PSCustomObject]$props - - # Display the custom object. - $EnvironmentObject | Format-List - + Get-Content -Path $env:GITHUB_STATE } Write-Output '┗━━━━━━━━━━━━━━━━━━━━━━━━━━━┛' From 5585e36ce8e95de9109c1a16fc283b188b1903a2 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 18 Jan 2025 13:25:04 +0100 Subject: [PATCH 17/21] Add logging for environment variables to capture RUNNER_* values --- scripts/main.ps1 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 537bed9..8cfa610 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -115,6 +115,19 @@ process { Get-Content -Path $env:GITHUB_STATE } + LogGroup ' - Environment Variables' { + $props = @{} + + Get-ChildItem Env: | Where-Object { $_.Name -like 'RUNNER_*' } | ForEach-Object { + $props[$_.Name] = $_.Value + } + + $customObject = [PSCustomObject]$props + + $customObject | Format-List + } + + Write-Output '┗━━━━━━━━━━━━━━━━━━━━━━━━━━━┛' } catch { From c100755305a60484eef25162935d201917ef5389 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 18 Jan 2025 13:28:06 +0100 Subject: [PATCH 18/21] Refactor environment variable logging to remove 'RUNNER_' prefix for improved clarity --- scripts/main.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 8cfa610..ced7b9c 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -119,7 +119,9 @@ process { $props = @{} Get-ChildItem Env: | Where-Object { $_.Name -like 'RUNNER_*' } | ForEach-Object { - $props[$_.Name] = $_.Value + $name = $_.Name + $name = $name -replace '^RUNNER_' + $props[$name] = $_.Value } $customObject = [PSCustomObject]$props From 4a961680e2bf1fbb29ecb8c145f315b1613294bd Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 18 Jan 2025 13:46:03 +0100 Subject: [PATCH 19/21] Refactor runner info logging to utilize Get-GithubRunnerData for improved clarity and maintainability --- scripts/main.ps1 | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index ced7b9c..9f0a673 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -100,36 +100,9 @@ process { } LogGroup ' - Runner Info' { - [pscustomobject]@{ - Name = $env:RUNNER_NAME - OS = $env:RUNNER_OS - Arch = $env:RUNNER_ARCH - Environment = $env:RUNNER_ENVIRONMENT - Temp = $env:RUNNER_TEMP - Perflog = $env:RUNNER_PERFLOG - ToolCache = $env:RUNNER_TOOL_CACHE - TrackingID = $env:RUNNER_TRACKING_ID - Workspace = $env:RUNNER_WORKSPACE - Processors = [System.Environment]::ProcessorCount - } | Format-List - Get-Content -Path $env:GITHUB_STATE + Get-GithubRunnerData | Format-List } - LogGroup ' - Environment Variables' { - $props = @{} - - Get-ChildItem Env: | Where-Object { $_.Name -like 'RUNNER_*' } | ForEach-Object { - $name = $_.Name - $name = $name -replace '^RUNNER_' - $props[$name] = $_.Value - } - - $customObject = [PSCustomObject]$props - - $customObject | Format-List - } - - Write-Output '┗━━━━━━━━━━━━━━━━━━━━━━━━━━━┛' } catch { From 2096912956f11998cf57e3bdb0a993088f1e71e8 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 19 Jan 2025 11:13:48 +0100 Subject: [PATCH 20/21] Add logging for GitHub event and runner data; update workflow triggers for pull requests --- .github/workflows/Auto-Release.yml | 11 +- .github/workflows/Linter.yml | 2 +- .github/workflows/TestWorkflow.yml | 408 ++++++++++++++--------------- scripts/main.ps1 | 9 - tests/info.ps1 | 9 + 5 files changed, 220 insertions(+), 219 deletions(-) create mode 100644 tests/info.ps1 diff --git a/.github/workflows/Auto-Release.yml b/.github/workflows/Auto-Release.yml index ade68ff..1a580b8 100644 --- a/.github/workflows/Auto-Release.yml +++ b/.github/workflows/Auto-Release.yml @@ -2,7 +2,16 @@ name: Auto-Release run-name: "Auto-Release - [${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}] by @${{ github.actor }}" -on: workflow_dispatch +on: + pull_request_target: + branches: + - main + types: + - closed + - opened + - reopened + - synchronize + - labeled concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/Linter.yml b/.github/workflows/Linter.yml index d3b814d..9477fd5 100644 --- a/.github/workflows/Linter.yml +++ b/.github/workflows/Linter.yml @@ -2,7 +2,7 @@ name: Linter run-name: "Linter - [${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}] by @${{ github.actor }}" -on: workflow_dispatch +on: [pull_request] concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/TestWorkflow.yml b/.github/workflows/TestWorkflow.yml index 51be3b5..da21cbe 100644 --- a/.github/workflows/TestWorkflow.yml +++ b/.github/workflows/TestWorkflow.yml @@ -44,212 +44,204 @@ jobs: - name: Action-Test uses: ./ with: + Debug: true + Verbose: true + + ActionTestWithScript: + name: WithScript + runs-on: ${{ inputs.runs-on }} + steps: + # Need to check out as part of the test, as its a local action + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Action-Test + uses: ./ + with: + Debug: true + Verbose: true + Script: . '.\Tests\Script.ps1' + + ActionTestCommands: + name: Commands + Outputs + runs-on: ${{ inputs.runs-on }} + steps: + # Need to check out as part of the test, as its a local action + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Action-Test + uses: ./ + id: test + with: + Debug: true + Verbose: true Prerelease: true - # Debug: true - # Verbose: true - - # ActionTestWithScript: - # name: WithScript - # runs-on: ${{ inputs.runs-on }} - # steps: - # # Need to check out as part of the test, as its a local action - # - name: Checkout repo - # uses: actions/checkout@v4 - - # - name: Action-Test - # uses: ./ - # with: - # Debug: true - # Verbose: true - # Script: | - # LogGroup 'Get-GitHubZen' { - # Get-GitHubZen - # } - - # LogGroup 'Get-GitHubViewer' { - # Get-GitHubViewer -Fields name, login, id, databaseID - # } - - # ActionTestCommands: - # name: Commands + Outputs - # runs-on: ${{ inputs.runs-on }} - # steps: - # # Need to check out as part of the test, as its a local action - # - name: Checkout repo - # uses: actions/checkout@v4 - - # - name: Action-Test - # uses: ./ - # id: test - # with: - # Debug: true - # Verbose: true - # Prerelease: true - # ShowOutput: true - # Script: | - # LogGroup 'Get-GitHubZen' { - # $cat = Get-GitHubOctocat - # $zen = Get-GitHubZen - # Set-GitHubEnvironmentVariable -Name 'OCTOCAT' -Value $cat - # } - - # LogGroup 'Set outputs - WISECAT' { - # Set-GitHubOutput -Name 'WISECAT' -Value $cat - # } - - # LogGroup 'Set outputs - Zen' { - # Set-GitHubOutput -Name 'Zen' -Value $zen - # } - - # LogGroup 'Set outputs - Context' { - # Set-GitHubOutput -Name 'Context' -Value (Get-GitHubContext) - # } - - # LogGroup 'Set outputs - GitConfig' { - # Set-GitHubOutput -Name 'GitConfig' -Value (Get-GitHubGitConfig -Scope system) - # } - - # LogGroup 'Set outputs - Zen2' { - # Set-GitHubOutput -Name 'Zen2' -Value $zen - # } - - # - name: Run-test - # shell: pwsh - # env: - # result: ${{ steps.test.outputs.result }} - # WISECAT: ${{ fromJson(steps.test.outputs.result).WISECAT }} - # run: | - # $result = $env:result | ConvertFrom-Json - # Set-GitHubStepSummary -Summary $env:WISECAT - # Write-GitHubNotice -Message $result.Zen -Title 'GitHub Zen' - # Write-Host ($result.Zen2) - # $result.Context | Format-List - # $result.GitConfig | Format-List - - # ActionTestWithoutToken: - # name: WithoutToken - # runs-on: ${{ inputs.runs-on }} - # steps: - # # Need to check out as part of the test, as its a local action - # - name: Checkout repo - # uses: actions/checkout@v4 - - # - name: Action-Test - # uses: ./ - # with: - # Token: '' - # Script: | - # LogGroup 'My group' { - # 'This is a group' - # } - - # ActionTestWithPAT: - # name: WithPAT - # runs-on: ${{ inputs.runs-on }} - # steps: - # # Need to check out as part of the test, as its a local action - # - name: Checkout repo - # uses: actions/checkout@v4 - - # - name: Action-Test - # uses: ./ - # with: - # Token: ${{ secrets.TEST_USER_PAT }} - # Script: | - # LogGroup 'Get-GitHubUser' { - # Get-GitHubUser | Format-Table -AutoSize - # } - - # ActionTestWithUSERFGPAT: - # name: WithUserFGPAT - # runs-on: ${{ inputs.runs-on }} - # steps: - # # Need to check out as part of the test, as its a local action - # - name: Checkout repo - # uses: actions/checkout@v4 - - # - name: Action-Test - # uses: ./ - # with: - # Token: ${{ secrets.TEST_USER_USER_FG_PAT }} - # Script: | - # LogGroup 'Get-GitHubUser' { - # Get-GitHubUser | Format-Table -AutoSize - # } - - # ActionTestWithORGFGPAT: - # name: WithOrgFGPAT - # runs-on: ${{ inputs.runs-on }} - # steps: - # # Need to check out as part of the test, as its a local action - # - name: Checkout repo - # uses: actions/checkout@v4 - - # - name: Action-Test - # uses: ./ - # with: - # Token: ${{ secrets.TEST_USER_ORG_FG_PAT }} - # Script: | - # LogGroup 'Get-GitHubUser' { - # Get-GitHubUser | Format-Table -AutoSize - # } - - # ActionTestWithGitHubAppEnt: - # name: GitHubAppEnt - # runs-on: ${{ inputs.runs-on }} - # steps: - # # Need to check out as part of the test, as its a local action - # - name: Checkout repo - # uses: actions/checkout@v4 - - # - name: Action-Test - # uses: ./ - # with: - # ClientID: ${{ secrets.TEST_APP_ENT_CLIENT_ID }} - # PrivateKey: ${{ secrets.TEST_APP_ENT_PRIVATE_KEY }} - # Script: | - # LogGroup 'Get-GitHubApp' { - # Get-GitHubApp | Format-Table -AutoSize - # } - - # LogGroup 'Get-GitHubAppInstallation' { - # Get-GitHubAppInstallation | Format-Table -AutoSize - # } - - # LogGroup 'Do something as an installation' { - # Get-GithubAppInstallation | New-GitHubAppInstallationAccessToken | ForEach-Object { - # Connect-GitHub -Token $_.token -Silent - # Get-GitHubContext | Format-Table -AutoSize - # Get-GitHubGitConfig | Format-Table -AutoSize - # } - # } - - # ActionTestWithGitHubAppOrg: - # name: GitHubAppOrg - # runs-on: ${{ inputs.runs-on }} - # steps: - # # Need to check out as part of the test, as its a local action - # - name: Checkout repo - # uses: actions/checkout@v4 - - # - name: Action-Test - # uses: ./ - # with: - # ClientID: ${{ secrets.TEST_APP_ORG_CLIENT_ID }} - # PrivateKey: ${{ secrets.TEST_APP_ORG_PRIVATE_KEY }} - # Script: | - # LogGroup 'Get-GitHubApp' { - # Get-GitHubApp | Format-Table -AutoSize - # } - - # LogGroup 'Get-GitHubAppInstallation' { - # Get-GitHubAppInstallation | Format-Table -AutoSize - # } - - # LogGroup 'Do something as an installation' { - # Get-GithubAppInstallation | New-GitHubAppInstallationAccessToken | ForEach-Object { - # Connect-GitHub -Token $_.token -Silent - # Get-GitHubContext | Format-Table -AutoSize - # Get-GitHubGitConfig | Format-Table -AutoSize - # } - # } + ShowOutput: true + Script: | + LogGroup 'Get-GitHubZen' { + $cat = Get-GitHubOctocat + $zen = Get-GitHubZen + Set-GitHubEnvironmentVariable -Name 'OCTOCAT' -Value $cat + } + + LogGroup 'Set outputs - WISECAT' { + Set-GitHubOutput -Name 'WISECAT' -Value $cat + } + + LogGroup 'Set outputs - Zen' { + Set-GitHubOutput -Name 'Zen' -Value $zen + } + + LogGroup 'Set outputs - Context' { + Set-GitHubOutput -Name 'Context' -Value (Get-GitHubContext) + } + + LogGroup 'Set outputs - GitConfig' { + Set-GitHubOutput -Name 'GitConfig' -Value (Get-GitHubGitConfig -Scope system) + } + + LogGroup 'Set outputs - Zen2' { + Set-GitHubOutput -Name 'Zen2' -Value $zen + } + + - name: Run-test + shell: pwsh + env: + result: ${{ steps.test.outputs.result }} + WISECAT: ${{ fromJson(steps.test.outputs.result).WISECAT }} + run: | + $result = $env:result | ConvertFrom-Json + Set-GitHubStepSummary -Summary $env:WISECAT + Write-GitHubNotice -Message $result.Zen -Title 'GitHub Zen' + Write-Host ($result.Zen2) + $result.Context | Format-List + $result.GitConfig | Format-List + + ActionTestWithoutToken: + name: WithoutToken + runs-on: ${{ inputs.runs-on }} + steps: + # Need to check out as part of the test, as its a local action + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Action-Test + uses: ./ + with: + Token: '' + Script: | + LogGroup 'My group' { + 'This is a group' + } + + ActionTestWithPAT: + name: WithPAT + runs-on: ${{ inputs.runs-on }} + steps: + # Need to check out as part of the test, as its a local action + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Action-Test + uses: ./ + with: + Token: ${{ secrets.TEST_USER_PAT }} + Script: | + LogGroup 'Get-GitHubUser' { + Get-GitHubUser | Format-Table -AutoSize + } + + ActionTestWithUSERFGPAT: + name: WithUserFGPAT + runs-on: ${{ inputs.runs-on }} + steps: + # Need to check out as part of the test, as its a local action + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Action-Test + uses: ./ + with: + Token: ${{ secrets.TEST_USER_USER_FG_PAT }} + Script: | + LogGroup 'Get-GitHubUser' { + Get-GitHubUser | Format-Table -AutoSize + } + + ActionTestWithORGFGPAT: + name: WithOrgFGPAT + runs-on: ${{ inputs.runs-on }} + steps: + # Need to check out as part of the test, as its a local action + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Action-Test + uses: ./ + with: + Token: ${{ secrets.TEST_USER_ORG_FG_PAT }} + Script: | + LogGroup 'Get-GitHubUser' { + Get-GitHubUser | Format-Table -AutoSize + } + + ActionTestWithGitHubAppEnt: + name: GitHubAppEnt + runs-on: ${{ inputs.runs-on }} + steps: + # Need to check out as part of the test, as its a local action + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Action-Test + uses: ./ + with: + ClientID: ${{ secrets.TEST_APP_ENT_CLIENT_ID }} + PrivateKey: ${{ secrets.TEST_APP_ENT_PRIVATE_KEY }} + Script: | + LogGroup 'Get-GitHubApp' { + Get-GitHubApp | Format-Table -AutoSize + } + + LogGroup 'Get-GitHubAppInstallation' { + Get-GitHubAppInstallation | Format-Table -AutoSize + } + + LogGroup 'Do something as an installation' { + Get-GithubAppInstallation | New-GitHubAppInstallationAccessToken | ForEach-Object { + Connect-GitHub -Token $_.token -Silent + Get-GitHubContext | Format-Table -AutoSize + Get-GitHubGitConfig | Format-Table -AutoSize + } + } + + ActionTestWithGitHubAppOrg: + name: GitHubAppOrg + runs-on: ${{ inputs.runs-on }} + steps: + # Need to check out as part of the test, as its a local action + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Action-Test + uses: ./ + with: + ClientID: ${{ secrets.TEST_APP_ORG_CLIENT_ID }} + PrivateKey: ${{ secrets.TEST_APP_ORG_PRIVATE_KEY }} + Script: | + LogGroup 'Get-GitHubApp' { + Get-GitHubApp | Format-Table -AutoSize + } + + LogGroup 'Get-GitHubAppInstallation' { + Get-GitHubAppInstallation | Format-Table -AutoSize + } + + LogGroup 'Do something as an installation' { + Get-GithubAppInstallation | New-GitHubAppInstallationAccessToken | ForEach-Object { + Connect-GitHub -Token $_.token -Silent + Get-GitHubContext | Format-Table -AutoSize + Get-GitHubGitConfig | Format-Table -AutoSize + } + } diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 9f0a673..5bce82b 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -95,16 +95,7 @@ process { Get-GitHubConfig | Format-List } - LogGroup ' - Event Info' { - Get-GithubEventData | Format-List - } - - LogGroup ' - Runner Info' { - Get-GithubRunnerData | Format-List - } - Write-Output '┗━━━━━━━━━━━━━━━━━━━━━━━━━━━┛' - } catch { throw $_ } diff --git a/tests/info.ps1 b/tests/info.ps1 new file mode 100644 index 0000000..0bff623 --- /dev/null +++ b/tests/info.ps1 @@ -0,0 +1,9 @@ +#Requires -Modules GitHub + +LogGroup ' - Event Info' { + Get-GithubEventData | Format-List +} + +LogGroup ' - Runner Info' { + Get-GithubRunnerData | Format-List +} From f4d8fff16766bfd13faa2e30d7b0ac37e1f837fc Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 19 Jan 2025 11:16:55 +0100 Subject: [PATCH 21/21] Update script path in TestWorkflow.yml to point to info.ps1 for improved organization --- .github/workflows/TestWorkflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/TestWorkflow.yml b/.github/workflows/TestWorkflow.yml index da21cbe..f2310a1 100644 --- a/.github/workflows/TestWorkflow.yml +++ b/.github/workflows/TestWorkflow.yml @@ -60,7 +60,7 @@ jobs: with: Debug: true Verbose: true - Script: . '.\Tests\Script.ps1' + Script: . '.\tests\info.ps1' ActionTestCommands: name: Commands + Outputs