From 030d02d63320e41f11b0f796e8b5b54f9e873dab Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 9 Dec 2024 17:56:32 +0100 Subject: [PATCH 1/7] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Refactor=20Action?= =?UTF-8?q?-Test=20workflow=20to=20simplify=20steps=20and=20enhance=20debu?= =?UTF-8?q?gging=20options?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Action-Test.yml | 254 +++++++++++++++--------------- 1 file changed, 129 insertions(+), 125 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index bbd12ae..4cb903d 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -20,113 +20,6 @@ jobs: ActionTestBasic: name: Action-Test - [Basic] runs-on: ubuntu-latest - 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: ./ - - ActionTestWithScript: - name: Action-Test - [WithScript] - runs-on: ubuntu-latest - 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: - Script: | - LogGroup 'Get-GitHubZen' { - Get-GitHubZen - } - - ActionTestCommands: - name: Action-Test - [Commands] - runs-on: ubuntu-latest - 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: - Prerelease: true - Script: | - $cat = Get-GitHubOctocat - $zen = Get-GitHubZen - Set-GitHubEnvironmentVariable -Name 'OCTOCAT' -Value $cat - Set-GitHubOutput -Name 'WISECAT' -Value $cat - Set-GitHubOutput -Name 'Zen' -Value $zen - - - name: Run-test - shell: pwsh - env: - result: ${{ steps.test.outputs.result }} - run: | - $result = $env:result | ConvertFrom-Json - Set-GitHubStepSummary -Summary $result.WISECAT - Write-GitHubNotice -Message $result.Zen -Title 'GitHub Zen' - - ActionTestWithoutToken: - name: Action-Test - [WithoutToken] - runs-on: ubuntu-latest - 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: Action-Test - [WithPAT] - runs-on: ubuntu-latest - 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_PAT }} - Script: | - LogGroup 'Get-GitHubUser' { - Get-GitHubUser | Format-Table -AutoSize - } - - ActionTestWithFGPAT: - name: Action-Test - [WithFGPAT] - runs-on: ubuntu-latest - 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_FG_PAT }} - Script: | - LogGroup 'Get-GitHubUser' { - Get-GitHubUser | Format-Table -AutoSize - } - - ActionTestWithGitHubApp: - name: Action-Test - [GitHubApp] - runs-on: ubuntu-latest steps: # Need to check out as part of the test, as its a local action - name: Checkout repo @@ -135,21 +28,132 @@ jobs: - name: Action-Test uses: ./ with: - ClientID: ${{ secrets.TEST_APP_CLIENT_ID }} - PrivateKey: ${{ secrets.TEST_APP_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 - } - } + Debug: true + Verbose: true + + + # ActionTestWithScript: + # name: Action-Test - [WithScript] + # runs-on: ubuntu-latest + # 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: + # Script: | + # LogGroup 'Get-GitHubZen' { + # Get-GitHubZen + # } + + # ActionTestCommands: + # name: Action-Test - [Commands] + # runs-on: ubuntu-latest + # 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: + # Prerelease: true + # Script: | + # $cat = Get-GitHubOctocat + # $zen = Get-GitHubZen + # Set-GitHubEnvironmentVariable -Name 'OCTOCAT' -Value $cat + # Set-GitHubOutput -Name 'WISECAT' -Value $cat + # Set-GitHubOutput -Name 'Zen' -Value $zen + + # - name: Run-test + # shell: pwsh + # env: + # result: ${{ steps.test.outputs.result }} + # run: | + # $result = $env:result | ConvertFrom-Json + # Set-GitHubStepSummary -Summary $result.WISECAT + # Write-GitHubNotice -Message $result.Zen -Title 'GitHub Zen' + + # ActionTestWithoutToken: + # name: Action-Test - [WithoutToken] + # runs-on: ubuntu-latest + # 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: Action-Test - [WithPAT] + # runs-on: ubuntu-latest + # 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_PAT }} + # Script: | + # LogGroup 'Get-GitHubUser' { + # Get-GitHubUser | Format-Table -AutoSize + # } + + # ActionTestWithFGPAT: + # name: Action-Test - [WithFGPAT] + # runs-on: ubuntu-latest + # 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_FG_PAT }} + # Script: | + # LogGroup 'Get-GitHubUser' { + # Get-GitHubUser | Format-Table -AutoSize + # } + + # ActionTestWithGitHubApp: + # name: Action-Test - [GitHubApp] + # runs-on: ubuntu-latest + # 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_CLIENT_ID }} + # PrivateKey: ${{ secrets.TEST_APP_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 + # } + # } From 799363e02032d5863568743a8f2f9ff5838538ec Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 9 Dec 2024 22:24:59 +0100 Subject: [PATCH 2/7] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Update=20Action-T?= =?UTF-8?q?est=20workflow=20to=20include=20debugging=20options=20and=20str?= =?UTF-8?q?eamline=20script=20execution?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Action-Test.yml | 254 +++++++++++++++--------------- 1 file changed, 129 insertions(+), 125 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 4cb903d..f240ba5 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -32,128 +32,132 @@ jobs: Verbose: true - # ActionTestWithScript: - # name: Action-Test - [WithScript] - # runs-on: ubuntu-latest - # 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: - # Script: | - # LogGroup 'Get-GitHubZen' { - # Get-GitHubZen - # } - - # ActionTestCommands: - # name: Action-Test - [Commands] - # runs-on: ubuntu-latest - # 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: - # Prerelease: true - # Script: | - # $cat = Get-GitHubOctocat - # $zen = Get-GitHubZen - # Set-GitHubEnvironmentVariable -Name 'OCTOCAT' -Value $cat - # Set-GitHubOutput -Name 'WISECAT' -Value $cat - # Set-GitHubOutput -Name 'Zen' -Value $zen - - # - name: Run-test - # shell: pwsh - # env: - # result: ${{ steps.test.outputs.result }} - # run: | - # $result = $env:result | ConvertFrom-Json - # Set-GitHubStepSummary -Summary $result.WISECAT - # Write-GitHubNotice -Message $result.Zen -Title 'GitHub Zen' - - # ActionTestWithoutToken: - # name: Action-Test - [WithoutToken] - # runs-on: ubuntu-latest - # 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: Action-Test - [WithPAT] - # runs-on: ubuntu-latest - # 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_PAT }} - # Script: | - # LogGroup 'Get-GitHubUser' { - # Get-GitHubUser | Format-Table -AutoSize - # } - - # ActionTestWithFGPAT: - # name: Action-Test - [WithFGPAT] - # runs-on: ubuntu-latest - # 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_FG_PAT }} - # Script: | - # LogGroup 'Get-GitHubUser' { - # Get-GitHubUser | Format-Table -AutoSize - # } - - # ActionTestWithGitHubApp: - # name: Action-Test - [GitHubApp] - # runs-on: ubuntu-latest - # 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_CLIENT_ID }} - # PrivateKey: ${{ secrets.TEST_APP_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 - # } - # } + ActionTestWithScript: + name: Action-Test - [WithScript] + runs-on: ubuntu-latest + 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 + } + + ActionTestCommands: + name: Action-Test - [Commands] + runs-on: ubuntu-latest + 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 + Script: | + $cat = Get-GitHubOctocat + $zen = Get-GitHubZen + Set-GitHubEnvironmentVariable -Name 'OCTOCAT' -Value $cat + Set-GitHubOutput -Name 'WISECAT' -Value $cat + Set-GitHubOutput -Name 'Zen' -Value $zen + + - name: Run-test + shell: pwsh + env: + result: ${{ steps.test.outputs.result }} + run: | + $result = $env:result | ConvertFrom-Json + Set-GitHubStepSummary -Summary $result.WISECAT + Write-GitHubNotice -Message $result.Zen -Title 'GitHub Zen' + + ActionTestWithoutToken: + name: Action-Test - [WithoutToken] + runs-on: ubuntu-latest + 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: Action-Test - [WithPAT] + runs-on: ubuntu-latest + 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_PAT }} + Script: | + LogGroup 'Get-GitHubUser' { + Get-GitHubUser | Format-Table -AutoSize + } + + ActionTestWithFGPAT: + name: Action-Test - [WithFGPAT] + runs-on: ubuntu-latest + 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_FG_PAT }} + Script: | + LogGroup 'Get-GitHubUser' { + Get-GitHubUser | Format-Table -AutoSize + } + + ActionTestWithGitHubApp: + name: Action-Test - [GitHubApp] + runs-on: ubuntu-latest + 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_CLIENT_ID }} + PrivateKey: ${{ secrets.TEST_APP_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 + } + } From 9cd88cfa7104f21daff1e4ce05d10111f1d914de Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 10 Dec 2024 22:29:04 +0100 Subject: [PATCH 3/7] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Add=20logging=20f?= =?UTF-8?q?or=20Get-GitHubViewer=20in=20Action-Test=20workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Action-Test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index f240ba5..b1809e2 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -50,6 +50,10 @@ jobs: Get-GitHubZen } + LogGroup 'Get-GitHubViewer' { + Get-GitHubViewer + } + ActionTestCommands: name: Action-Test - [Commands] runs-on: ubuntu-latest From 41f74d33b19ddda718bbb8fd08b9229010db08ce Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Tue, 10 Dec 2024 22:30:57 +0100 Subject: [PATCH 4/7] test --- .github/workflows/Action-Test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index b1809e2..400e5f9 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -51,7 +51,7 @@ jobs: } LogGroup 'Get-GitHubViewer' { - Get-GitHubViewer + Get-GitHubViewer -Fields name, login, id, databaseID } ActionTestCommands: From 988a654b26008d762473c100a64cffb435dd67a4 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 11 Dec 2024 00:52:41 +0100 Subject: [PATCH 5/7] cleanup --- scripts/main.ps1 | 5 ----- 1 file changed, 5 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index abbe63d..5c8d124 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -55,14 +55,9 @@ Write-Output 'GitHub module configuration:' Get-GitHubConfig | Select-Object Name, ID, RunEnv | Format-Table -AutoSize '::endgroup::' - $providedToken = -not [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_Token) $providedClientID = -not [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_ClientID) $providedPrivateKey = -not [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_PrivateKey) -Write-Verbose 'Provided authentication info:' -Write-Verbose "Token: [$providedToken]" -Write-Verbose "ClientID: [$providedClientID]" -Write-Verbose "PrivateKey: [$providedPrivateKey]" if ($providedClientID -and $providedPrivateKey) { LogGroup 'Connecting using provided GitHub App' { From fcb68ba28b43679e634a9eb2215088f8e336b2a4 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 11 Dec 2024 01:05:52 +0100 Subject: [PATCH 6/7] Update Debug/Verbose --- scripts/main.ps1 | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 5c8d124..905f225 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -1,12 +1,8 @@ [CmdletBinding()] param() -if ($env:GITHUB_ACTION_INPUT_Debug -eq 'true') { - $DebugPreference = 'Continue' -} -if ($env:GITHUB_ACTION_INPUT_Verbose -eq 'true') { - $VerbosePreference = 'Continue' -} +$DebugPreference = $env:GITHUB_ACTION_INPUT_Debug -eq 'true' ? 'Continue' : 'SilentlyContinue' +$VerbosePreference = $env:GITHUB_ACTION_INPUT_Verbose -eq 'true' ? 'Continue' : 'SilentlyContinue' '::group::Setting up GitHub PowerShell module' $env:PSMODULE_GITHUB_SCRIPT = $true @@ -55,9 +51,14 @@ Write-Output 'GitHub module configuration:' Get-GitHubConfig | Select-Object Name, ID, RunEnv | Format-Table -AutoSize '::endgroup::' + $providedToken = -not [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_Token) $providedClientID = -not [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_ClientID) $providedPrivateKey = -not [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_PrivateKey) +Write-Verbose 'Provided authentication info:' +Write-Verbose "Token: [$providedToken]" +Write-Verbose "ClientID: [$providedClientID]" +Write-Verbose "PrivateKey: [$providedPrivateKey]" if ($providedClientID -and $providedPrivateKey) { LogGroup 'Connecting using provided GitHub App' { From a8ab7b2a40dbcd3db8356377afcc93cd653404c3 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Wed, 11 Dec 2024 01:10:20 +0100 Subject: [PATCH 7/7] Remove unnecessary blank line in Action-Test workflow --- .github/workflows/Action-Test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 400e5f9..ea4866d 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -31,7 +31,6 @@ jobs: Debug: true Verbose: true - ActionTestWithScript: name: Action-Test - [WithScript] runs-on: ubuntu-latest