From acdb9dd5fe8311c41a6139cc5f53a9e9a344d9cd Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 12:33:59 +0100 Subject: [PATCH 01/38] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Add=20Action-Te?= =?UTF-8?q?st=20commands=20to=20GitHub=20workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Action-Test.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 725f1c0..564806e 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -44,6 +44,33 @@ jobs: 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: action-test + with: + Script: | + $cat = Get-GitHubOctocat + Set-Content -Path 'octocat.md' -Value $cat + Set-GitHubEnvironmentVariable -Name 'OCTOCAT' -Value $cat + Set-GitHubOutput -Name 'octocat' -Value $cat + Set-GitHubStepSummary -Summary $cat + + - name: Action-Test + uses: ./ + with: + Script: | + "${{ steps.action-test.outputs.octocat }}" + "${{ env.OCTOCAT }}" + + ActionTestWithoutToken: name: Action-Test - [WithoutToken] runs-on: ubuntu-latest From fc16178ebaccfe6b571590105155973cffb65b09 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 12:36:59 +0100 Subject: [PATCH 02/38] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Enable=20Prerel?= =?UTF-8?q?ease=20option=20in=20Action-Test=20workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Action-Test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 564806e..522e60d 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -56,6 +56,7 @@ jobs: uses: ./ id: action-test with: + Prerelease: true Script: | $cat = Get-GitHubOctocat Set-Content -Path 'octocat.md' -Value $cat From 54f359bc04c477e8c757434026b6ff0e294a9923 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 12:38:43 +0100 Subject: [PATCH 03/38] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Update=20Action?= =?UTF-8?q?-Test=20workflow=20to=20use=20PowerShell=20variable=20syntax=20?= =?UTF-8?q?for=20OCTOCAT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .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 522e60d..5553047 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -69,7 +69,7 @@ jobs: with: Script: | "${{ steps.action-test.outputs.octocat }}" - "${{ env.OCTOCAT }}" + "$env:OCTOCAT" ActionTestWithoutToken: From 8c8eae080d4474eb1f4653e2deb4f43f7968c973 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 12:44:53 +0100 Subject: [PATCH 04/38] test --- .github/workflows/Action-Test.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 5553047..b12fd66 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -68,8 +68,7 @@ jobs: uses: ./ with: Script: | - "${{ steps.action-test.outputs.octocat }}" - "$env:OCTOCAT" + $env:OCTOCAT ActionTestWithoutToken: From e59ac16d042f1c99a383eb0298182469e0ae9eda Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 12:48:46 +0100 Subject: [PATCH 05/38] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Rename=20Action?= =?UTF-8?q?-Test=20job=20and=20add=20Action-Test-Output=20step=20for=20env?= =?UTF-8?q?ironment=20variable=20handling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Action-Test.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index b12fd66..0e46373 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -64,12 +64,20 @@ jobs: Set-GitHubOutput -Name 'octocat' -Value $cat Set-GitHubStepSummary -Summary $cat - - name: Action-Test + - name: Action-Test-Env uses: ./ with: Script: | $env:OCTOCAT + - name: Action-Test-Output + uses: ./ + env: + wisecat: ${{ steps.action-test.outputs.octocat }} + with: + Script: | + $env:wisecat + ActionTestWithoutToken: name: Action-Test - [WithoutToken] From 6c40fd1bedd3a7a3c41dc997a39e7a531916dd82 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 12:51:07 +0100 Subject: [PATCH 06/38] verbose tests --- .github/workflows/Action-Test.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 0e46373..52bf931 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -61,7 +61,7 @@ jobs: $cat = Get-GitHubOctocat Set-Content -Path 'octocat.md' -Value $cat Set-GitHubEnvironmentVariable -Name 'OCTOCAT' -Value $cat - Set-GitHubOutput -Name 'octocat' -Value $cat + Set-GitHubOutput -Name 'octocat' -Value $cat -Verbose Set-GitHubStepSummary -Summary $cat - name: Action-Test-Env @@ -78,7 +78,6 @@ jobs: Script: | $env:wisecat - ActionTestWithoutToken: name: Action-Test - [WithoutToken] runs-on: ubuntu-latest From 57d69f2bd5fe4c37707c694ff01dc94c9b5d1e46 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 13:05:32 +0100 Subject: [PATCH 07/38] Get content --- .github/workflows/Action-Test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 52bf931..96e1642 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -64,6 +64,8 @@ jobs: Set-GitHubOutput -Name 'octocat' -Value $cat -Verbose Set-GitHubStepSummary -Summary $cat + Get-Content -Path $env:GITHUB_OUTPUT + - name: Action-Test-Env uses: ./ with: From b1358ac9a1969fd9c52443634d85ec3550379501 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 13:07:27 +0100 Subject: [PATCH 08/38] test casing --- .github/workflows/Action-Test.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 96e1642..84970c8 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -61,11 +61,9 @@ jobs: $cat = Get-GitHubOctocat Set-Content -Path 'octocat.md' -Value $cat Set-GitHubEnvironmentVariable -Name 'OCTOCAT' -Value $cat - Set-GitHubOutput -Name 'octocat' -Value $cat -Verbose + Set-GitHubOutput -Name 'WISECAT' -Value $cat -Verbose Set-GitHubStepSummary -Summary $cat - Get-Content -Path $env:GITHUB_OUTPUT - - name: Action-Test-Env uses: ./ with: @@ -75,10 +73,10 @@ jobs: - name: Action-Test-Output uses: ./ env: - wisecat: ${{ steps.action-test.outputs.octocat }} + WISECAT: ${{ steps.action-test.outputs.WISECAT }} with: Script: | - $env:wisecat + $env:WISECAT ActionTestWithoutToken: name: Action-Test - [WithoutToken] From 1f39402bca1d7c9b43a1a25c0cab7ca402b20332 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 13:16:55 +0100 Subject: [PATCH 09/38] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Update=20Action?= =?UTF-8?q?-Test=20job=20to=20modify=20output=20handling=20with=20new=20GU?= =?UTF-8?q?ID=20method?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Action-Test.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 84970c8..649cb57 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -61,7 +61,13 @@ jobs: $cat = Get-GitHubOctocat Set-Content -Path 'octocat.md' -Value $cat Set-GitHubEnvironmentVariable -Name 'OCTOCAT' -Value $cat - Set-GitHubOutput -Name 'WISECAT' -Value $cat -Verbose + # Set-GitHubOutput -Name 'WISECAT' -Value $cat -Verbose + $guid = (New-Guid).Guid + "wisecat2<<$guid" >> $env:GITHUB_OUTPUT + $cat.split("`n") | ForEach-Object { + $_ >> $env:GITHUB_OUTPUT + } + $guid >> $env:GITHUB_OUTPUT Set-GitHubStepSummary -Summary $cat - name: Action-Test-Env From 8c5ae1577cd4b2519371cb6229e32cb81f834d64 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 13:17:13 +0100 Subject: [PATCH 10/38] =?UTF-8?q?=F0=9F=A9=B9=20[Patch]:=20Update=20Action?= =?UTF-8?q?-Test=20job=20to=20change=20output=20variable=20from=20WISECAT?= =?UTF-8?q?=20to=20WISECAT2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Action-Test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 649cb57..aa8e521 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -63,7 +63,7 @@ jobs: Set-GitHubEnvironmentVariable -Name 'OCTOCAT' -Value $cat # Set-GitHubOutput -Name 'WISECAT' -Value $cat -Verbose $guid = (New-Guid).Guid - "wisecat2<<$guid" >> $env:GITHUB_OUTPUT + "WISECAT2<<$guid" >> $env:GITHUB_OUTPUT $cat.split("`n") | ForEach-Object { $_ >> $env:GITHUB_OUTPUT } @@ -79,10 +79,10 @@ jobs: - name: Action-Test-Output uses: ./ env: - WISECAT: ${{ steps.action-test.outputs.WISECAT }} + WISECAT2: ${{ steps.action-test.outputs.WISECAT2 }} with: Script: | - $env:WISECAT + $env:WISECAT2 ActionTestWithoutToken: name: Action-Test - [WithoutToken] From ef964a34087adf8a168c65f5f7b3e1172fcd3e76 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 13:24:24 +0100 Subject: [PATCH 11/38] test --- .github/workflows/Action-Test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index aa8e521..73fc208 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -62,12 +62,12 @@ jobs: Set-Content -Path 'octocat.md' -Value $cat Set-GitHubEnvironmentVariable -Name 'OCTOCAT' -Value $cat # Set-GitHubOutput -Name 'WISECAT' -Value $cat -Verbose - $guid = (New-Guid).Guid - "WISECAT2<<$guid" >> $env:GITHUB_OUTPUT + + "WISECAT2<> $env:GITHUB_OUTPUT $cat.split("`n") | ForEach-Object { $_ >> $env:GITHUB_OUTPUT } - $guid >> $env:GITHUB_OUTPUT + EOF >> $env:GITHUB_OUTPUT Set-GitHubStepSummary -Summary $cat - name: Action-Test-Env From 7e9ba51a9cc10f1c6c246bde1a0514aa76f94eaa Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 13:27:33 +0100 Subject: [PATCH 12/38] 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 73fc208..6f262a0 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -67,7 +67,7 @@ jobs: $cat.split("`n") | ForEach-Object { $_ >> $env:GITHUB_OUTPUT } - EOF >> $env:GITHUB_OUTPUT + "EOF" >> $env:GITHUB_OUTPUT Set-GitHubStepSummary -Summary $cat - name: Action-Test-Env From fd18c1fbac77c1f941c39f6f554c6934229585ea Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 13:29:56 +0100 Subject: [PATCH 13/38] test --- .github/workflows/Action-Test.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 6f262a0..3a0193c 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -54,20 +54,19 @@ jobs: - name: Action-Test uses: ./ - id: action-test + id: action_test with: Prerelease: true Script: | $cat = Get-GitHubOctocat + $zen = Get-GitHubZen Set-Content -Path 'octocat.md' -Value $cat Set-GitHubEnvironmentVariable -Name 'OCTOCAT' -Value $cat # Set-GitHubOutput -Name 'WISECAT' -Value $cat -Verbose - "WISECAT2<> $env:GITHUB_OUTPUT - $cat.split("`n") | ForEach-Object { - $_ >> $env:GITHUB_OUTPUT - } - "EOF" >> $env:GITHUB_OUTPUT + 'WISECAT2<> $env:GITHUB_OUTPUT + $cat >> $env:GITHUB_OUTPUT + 'EOF' >> $env:GITHUB_OUTPUT Set-GitHubStepSummary -Summary $cat - name: Action-Test-Env @@ -79,7 +78,7 @@ jobs: - name: Action-Test-Output uses: ./ env: - WISECAT2: ${{ steps.action-test.outputs.WISECAT2 }} + WISECAT2: ${{ steps.action_test.outputs.WISECAT2 }} with: Script: | $env:WISECAT2 From bfb018881767c869991439169c38e3cba183d64c Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 13:39:03 +0100 Subject: [PATCH 14/38] test --- .github/workflows/Action-Test.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 3a0193c..b707382 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -54,7 +54,7 @@ jobs: - name: Action-Test uses: ./ - id: action_test + id: test with: Prerelease: true Script: | @@ -64,6 +64,8 @@ jobs: Set-GitHubEnvironmentVariable -Name 'OCTOCAT' -Value $cat # Set-GitHubOutput -Name 'WISECAT' -Value $cat -Verbose + "ZEN=$zen" >> $env:GITHUB_OUTPUT + 'WISECAT2<> $env:GITHUB_OUTPUT $cat >> $env:GITHUB_OUTPUT 'EOF' >> $env:GITHUB_OUTPUT @@ -78,10 +80,14 @@ jobs: - name: Action-Test-Output uses: ./ env: - WISECAT2: ${{ steps.action_test.outputs.WISECAT2 }} + WISECAT: ${{ steps.test.outputs.WISECAT }} + ZEN: ${{ steps.test.outputs.ZEN }} with: Script: | - $env:WISECAT2 + "Wisecat" + $env:WISECAT + "Zen" + $env:ZEN ActionTestWithoutToken: name: Action-Test - [WithoutToken] From d135ebf041cb44bdf834dc940885950cff3c800c Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 13:42:24 +0100 Subject: [PATCH 15/38] test --- .github/workflows/Action-Test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index b707382..e7320d1 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -71,6 +71,8 @@ jobs: 'EOF' >> $env:GITHUB_OUTPUT Set-GitHubStepSummary -Summary $cat + $env:GITHUB_OUTPUT + - name: Action-Test-Env uses: ./ with: From b8faed90b97255d28b4537a9635958dac75df947 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 13:44:41 +0100 Subject: [PATCH 16/38] test --- .github/workflows/Action-Test.yml | 213 +++++++++++++++--------------- 1 file changed, 107 insertions(+), 106 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index e7320d1..0e61650 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -17,32 +17,32 @@ permissions: pull-requests: read 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 - } + # 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] @@ -72,6 +72,7 @@ jobs: Set-GitHubStepSummary -Summary $cat $env:GITHUB_OUTPUT + Get-Content $env:GITHUB_OUTPUT - name: Action-Test-Env uses: ./ @@ -91,83 +92,83 @@ jobs: "Zen" $env: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 - } - } + # 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 64125a00a4c460e711218946fcce6483801efcb6 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 13:46:12 +0100 Subject: [PATCH 17/38] test --- .github/workflows/Action-Test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 0e61650..852e7cf 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -71,6 +71,7 @@ jobs: 'EOF' >> $env:GITHUB_OUTPUT Set-GitHubStepSummary -Summary $cat + $env:GITHUB_ACTION $env:GITHUB_OUTPUT Get-Content $env:GITHUB_OUTPUT From af814f3dfca701dccb2bcdb18914d2daabc4f35d Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 13:50:13 +0100 Subject: [PATCH 18/38] test --- .github/workflows/Action-Test.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 852e7cf..5295ae9 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -75,6 +75,13 @@ jobs: $env:GITHUB_OUTPUT Get-Content $env:GITHUB_OUTPUT + - name: test + id: test2 + shell: pwsh + run: | + $env:GITHUB_ACTION + "ZEN=WhatIsThis" >> $env:GITHUB_OUTPUT + - name: Action-Test-Env uses: ./ with: @@ -85,7 +92,7 @@ jobs: uses: ./ env: WISECAT: ${{ steps.test.outputs.WISECAT }} - ZEN: ${{ steps.test.outputs.ZEN }} + ZEN: ${{ steps.test2.outputs.ZEN }} with: Script: | "Wisecat" From 39d0846c0f32748c72a575d4084324499f1f7bf1 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 14:11:23 +0100 Subject: [PATCH 19/38] test --- .github/workflows/Action-Test.yml | 33 ++++++++++++++++--------------- action.yml | 6 ++++++ 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 5295ae9..49303ed 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -58,22 +58,23 @@ jobs: with: Prerelease: true Script: | - $cat = Get-GitHubOctocat - $zen = Get-GitHubZen - Set-Content -Path 'octocat.md' -Value $cat - Set-GitHubEnvironmentVariable -Name 'OCTOCAT' -Value $cat - # Set-GitHubOutput -Name 'WISECAT' -Value $cat -Verbose - - "ZEN=$zen" >> $env:GITHUB_OUTPUT - - 'WISECAT2<> $env:GITHUB_OUTPUT - $cat >> $env:GITHUB_OUTPUT - 'EOF' >> $env:GITHUB_OUTPUT - Set-GitHubStepSummary -Summary $cat - - $env:GITHUB_ACTION - $env:GITHUB_OUTPUT - Get-Content $env:GITHUB_OUTPUT + Get-ChildItem env: | Format-Table -AutoSize + # $cat = Get-GitHubOctocat + # $zen = Get-GitHubZen + # Set-Content -Path 'octocat.md' -Value $cat + # Set-GitHubEnvironmentVariable -Name 'OCTOCAT' -Value $cat + # # Set-GitHubOutput -Name 'WISECAT' -Value $cat -Verbose + + # "ZEN=$zen" >> $env:GITHUB_OUTPUT + + # 'WISECAT2<> $env:GITHUB_OUTPUT + # $cat >> $env:GITHUB_OUTPUT + # 'EOF' >> $env:GITHUB_OUTPUT + # Set-GitHubStepSummary -Summary $cat + + # $env:GITHUB_ACTION + # $env:GITHUB_OUTPUT + # Get-Content $env:GITHUB_OUTPUT - name: test id: test2 diff --git a/action.yml b/action.yml index 7f517c7..ca37511 100644 --- a/action.yml +++ b/action.yml @@ -39,11 +39,17 @@ inputs: required: false default: ${{ github.workspace }} +outputs: + return: + description: The output of the script. + value: ${{ steps.RunGitGubScript.outputs.return }} + runs: using: composite steps: - name: Install GitHub shell: pwsh + id: RunGitGubScript working-directory: ${{ inputs.WorkingDirectory }} env: GITHUB_ACTION_INPUT_Token: ${{ inputs.Token }} From 4205d7b7496d16ba07b810fdae3522aa3163d0c8 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 14:15:35 +0100 Subject: [PATCH 20/38] test --- scripts/main.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 2a6d1cf..2c79c8c 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -9,6 +9,7 @@ if ($env:GITHUB_ACTION_INPUT_Verbose -eq 'true') { } '::group::Setting up GitHub PowerShell module' +$env:PSMODULE_GITHUB_SCRIPT = $true $Name = 'GitHub' $Version = [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_Version) ? $null : $env:GITHUB_ACTION_INPUT_Version From 1502b4b0fcfdfda96500000b4b5c46f3e76d72dd Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 14:19:33 +0100 Subject: [PATCH 21/38] Add environment variable logging to main.ps1 --- scripts/main.ps1 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 2c79c8c..eba201c 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -10,6 +10,11 @@ if ($env:GITHUB_ACTION_INPUT_Verbose -eq 'true') { '::group::Setting up GitHub PowerShell module' $env:PSMODULE_GITHUB_SCRIPT = $true +"----------------------------------------------------------" +Get-ChildItem env: +'----------------------------------------------------------' +Get-Content $env:GITHUB_ENV +'----------------------------------------------------------' $Name = 'GitHub' $Version = [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_Version) ? $null : $env:GITHUB_ACTION_INPUT_Version From 295b807cb0dd507d31365e54b50cef770d8b2c1e Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 14:23:26 +0100 Subject: [PATCH 22/38] test --- .github/workflows/Action-Test.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 49303ed..685e2fc 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -80,8 +80,7 @@ jobs: id: test2 shell: pwsh run: | - $env:GITHUB_ACTION - "ZEN=WhatIsThis" >> $env:GITHUB_OUTPUT + Get-ChildItem env: | Format-Table -AutoSize - name: Action-Test-Env uses: ./ From d048a52afc7aa4c0ea907c257759f75297efd726 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 19:39:08 +0100 Subject: [PATCH 23/38] test --- action.yml | 5 +++-- scripts/main.ps1 | 9 ++------- scripts/outputs.ps1 | 3 +++ 3 files changed, 8 insertions(+), 9 deletions(-) create mode 100644 scripts/outputs.ps1 diff --git a/action.yml b/action.yml index ca37511..abcd75b 100644 --- a/action.yml +++ b/action.yml @@ -40,9 +40,9 @@ inputs: default: ${{ github.workspace }} outputs: - return: + result: description: The output of the script. - value: ${{ steps.RunGitGubScript.outputs.return }} + value: ${{ steps.RunGitGubScript.outputs.result }} runs: using: composite @@ -63,3 +63,4 @@ runs: # GitHub-Script . "${{ github.action_path }}\scripts\main.ps1" ${{ inputs.Script }} + . "${{ github.action_path }}\scripts\outputs.ps1" diff --git a/scripts/main.ps1 b/scripts/main.ps1 index eba201c..abbe63d 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -10,11 +10,6 @@ if ($env:GITHUB_ACTION_INPUT_Verbose -eq 'true') { '::group::Setting up GitHub PowerShell module' $env:PSMODULE_GITHUB_SCRIPT = $true -"----------------------------------------------------------" -Get-ChildItem env: -'----------------------------------------------------------' -Get-Content $env:GITHUB_ENV -'----------------------------------------------------------' $Name = 'GitHub' $Version = [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_Version) ? $null : $env:GITHUB_ACTION_INPUT_Version @@ -53,10 +48,10 @@ if (-not $alreadyImported) { Import-Module -Name $Name } -Write-Host 'Installed modules:' +Write-Output 'Installed modules:' Get-InstalledPSResource | Select-Object Name, Version, Prerelease | Format-Table -AutoSize -Write-Host 'GitHub module configuration:' +Write-Output 'GitHub module configuration:' Get-GitHubConfig | Select-Object Name, ID, RunEnv | Format-Table -AutoSize '::endgroup::' diff --git a/scripts/outputs.ps1 b/scripts/outputs.ps1 new file mode 100644 index 0000000..997eb8d --- /dev/null +++ b/scripts/outputs.ps1 @@ -0,0 +1,3 @@ +$outputs = Get-GitHubOutput +$env:PSMODULE_GITHUB_SCRIPT = $false +Set-GitHubOutput -Name 'result' -Value $outputs.result From 08f8a31d1b23d066e73769339e1d4185b7c30821 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 19:39:52 +0100 Subject: [PATCH 24/38] test --- .github/workflows/Action-Test.yml | 32 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 685e2fc..5392b2f 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -59,22 +59,22 @@ jobs: Prerelease: true Script: | Get-ChildItem env: | Format-Table -AutoSize - # $cat = Get-GitHubOctocat - # $zen = Get-GitHubZen - # Set-Content -Path 'octocat.md' -Value $cat - # Set-GitHubEnvironmentVariable -Name 'OCTOCAT' -Value $cat - # # Set-GitHubOutput -Name 'WISECAT' -Value $cat -Verbose - - # "ZEN=$zen" >> $env:GITHUB_OUTPUT - - # 'WISECAT2<> $env:GITHUB_OUTPUT - # $cat >> $env:GITHUB_OUTPUT - # 'EOF' >> $env:GITHUB_OUTPUT - # Set-GitHubStepSummary -Summary $cat - - # $env:GITHUB_ACTION - # $env:GITHUB_OUTPUT - # Get-Content $env:GITHUB_OUTPUT + $cat = Get-GitHubOctocat + $zen = Get-GitHubZen + Set-Content -Path 'octocat.md' -Value $cat + Set-GitHubEnvironmentVariable -Name 'OCTOCAT' -Value $cat + # Set-GitHubOutput -Name 'WISECAT' -Value $cat -Verbose + + "ZEN=$zen" >> $env:GITHUB_OUTPUT + + 'WISECAT2<> $env:GITHUB_OUTPUT + $cat >> $env:GITHUB_OUTPUT + 'EOF' >> $env:GITHUB_OUTPUT + Set-GitHubStepSummary -Summary $cat + + $env:GITHUB_ACTION + $env:GITHUB_OUTPUT + Get-Content $env:GITHUB_OUTPUT - name: test id: test2 From b870aedd26094e841c814355f77d8f6b15c18716 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 19:50:21 +0100 Subject: [PATCH 25/38] Refactor GitHub Actions output handling in Action-Test.yml --- .github/workflows/Action-Test.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 5392b2f..9ef76b6 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -63,13 +63,14 @@ jobs: $zen = Get-GitHubZen Set-Content -Path 'octocat.md' -Value $cat Set-GitHubEnvironmentVariable -Name 'OCTOCAT' -Value $cat - # Set-GitHubOutput -Name 'WISECAT' -Value $cat -Verbose + Set-GitHubOutput -Name 'WISECAT' -Value $cat + Set-GitHubOutput -Name 'Zen' -Value $zen - "ZEN=$zen" >> $env:GITHUB_OUTPUT + # "ZEN=$zen" >> $env:GITHUB_OUTPUT + # 'WISECAT2<> $env:GITHUB_OUTPUT + # $cat >> $env:GITHUB_OUTPUT + # 'EOF' >> $env:GITHUB_OUTPUT - 'WISECAT2<> $env:GITHUB_OUTPUT - $cat >> $env:GITHUB_OUTPUT - 'EOF' >> $env:GITHUB_OUTPUT Set-GitHubStepSummary -Summary $cat $env:GITHUB_ACTION From 5cedd8af31fda8a0b02f4842527902a90545a399 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 20:01:44 +0100 Subject: [PATCH 26/38] Add output logging to outputs.ps1 --- scripts/outputs.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/outputs.ps1 b/scripts/outputs.ps1 index 997eb8d..c347795 100644 --- a/scripts/outputs.ps1 +++ b/scripts/outputs.ps1 @@ -1,3 +1,4 @@ $outputs = Get-GitHubOutput +$outputs $env:PSMODULE_GITHUB_SCRIPT = $false Set-GitHubOutput -Name 'result' -Value $outputs.result From 2e8a0108dc70901a6dba3de5a8ce7d20d2a9c287 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 20:03:37 +0100 Subject: [PATCH 27/38] Fix --- .github/workflows/Action-Test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 9ef76b6..c03f4fa 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -66,10 +66,10 @@ jobs: Set-GitHubOutput -Name 'WISECAT' -Value $cat Set-GitHubOutput -Name 'Zen' -Value $zen - # "ZEN=$zen" >> $env:GITHUB_OUTPUT - # 'WISECAT2<> $env:GITHUB_OUTPUT - # $cat >> $env:GITHUB_OUTPUT - # 'EOF' >> $env:GITHUB_OUTPUT + "ZEN=$zen" >> $env:GITHUB_OUTPUT + 'WISECAT2<> $env:GITHUB_OUTPUT + $cat >> $env:GITHUB_OUTPUT + 'EOF' >> $env:GITHUB_OUTPUT Set-GitHubStepSummary -Summary $cat From 17c3ff3f94016cfb696afe7733e9eb4bf913c7cd Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 20:15:44 +0100 Subject: [PATCH 28/38] Remove unused environment variables from Action-Test.yml --- .github/workflows/Action-Test.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index c03f4fa..4624f5d 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -73,10 +73,6 @@ jobs: Set-GitHubStepSummary -Summary $cat - $env:GITHUB_ACTION - $env:GITHUB_OUTPUT - Get-Content $env:GITHUB_OUTPUT - - name: test id: test2 shell: pwsh From 12a038a8cd43ecd32f4c7e0e58afad0bc8111f97 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 20:20:21 +0100 Subject: [PATCH 29/38] Update outputs.ps1 to read GITHUB_OUTPUT content before fetching outputs --- scripts/outputs.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/outputs.ps1 b/scripts/outputs.ps1 index c347795..a63e798 100644 --- a/scripts/outputs.ps1 +++ b/scripts/outputs.ps1 @@ -1,4 +1,6 @@ -$outputs = Get-GitHubOutput + +Get-Content -Path $env:GITHUB_OUTPUT +$outputs = Get-GitHubOutput $outputs $env:PSMODULE_GITHUB_SCRIPT = $false Set-GitHubOutput -Name 'result' -Value $outputs.result From c4550e735dcb3cce69b57539262666cf2f0d4bd0 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 20:23:09 +0100 Subject: [PATCH 30/38] Update outputs.ps1 to fetch outputs using GITHUB_OUTPUT path --- scripts/outputs.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/outputs.ps1 b/scripts/outputs.ps1 index a63e798..5daa0f1 100644 --- a/scripts/outputs.ps1 +++ b/scripts/outputs.ps1 @@ -1,6 +1,6 @@  Get-Content -Path $env:GITHUB_OUTPUT -$outputs = Get-GitHubOutput +$outputs = Get-GitHubOutput -Path $env:GITHUB_OUTPUT $outputs $env:PSMODULE_GITHUB_SCRIPT = $false Set-GitHubOutput -Name 'result' -Value $outputs.result From 0ee249af83edec498e77f005fd284994f1700cc5 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 20:37:26 +0100 Subject: [PATCH 31/38] test --- .github/workflows/Action-Test.yml | 5 +---- scripts/outputs.ps1 | 8 ++++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 4624f5d..9e5f508 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -58,10 +58,8 @@ jobs: with: Prerelease: true Script: | - Get-ChildItem env: | Format-Table -AutoSize $cat = Get-GitHubOctocat $zen = Get-GitHubZen - Set-Content -Path 'octocat.md' -Value $cat Set-GitHubEnvironmentVariable -Name 'OCTOCAT' -Value $cat Set-GitHubOutput -Name 'WISECAT' -Value $cat Set-GitHubOutput -Name 'Zen' -Value $zen @@ -88,8 +86,7 @@ jobs: - name: Action-Test-Output uses: ./ env: - WISECAT: ${{ steps.test.outputs.WISECAT }} - ZEN: ${{ steps.test2.outputs.ZEN }} + result: ${{ steps.test.outputs.WISECAT }} with: Script: | "Wisecat" diff --git a/scripts/outputs.ps1 b/scripts/outputs.ps1 index 5daa0f1..fde761b 100644 --- a/scripts/outputs.ps1 +++ b/scripts/outputs.ps1 @@ -1,6 +1,6 @@  Get-Content -Path $env:GITHUB_OUTPUT -$outputs = Get-GitHubOutput -Path $env:GITHUB_OUTPUT -$outputs -$env:PSMODULE_GITHUB_SCRIPT = $false -Set-GitHubOutput -Name 'result' -Value $outputs.result +# $outputs = Get-GitHubOutput -Path $env:GITHUB_OUTPUT +# $outputs +# $env:PSMODULE_GITHUB_SCRIPT = $false +# Set-GitHubOutput -Name 'result' -Value $outputs.result From c2636d47a50401aaaf908d36af4f4cd62853f196 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 20:46:15 +0100 Subject: [PATCH 32/38] Refactor Action-Test workflow to streamline output handling and remove unused scripts --- .github/workflows/Action-Test.yml | 26 +++----------------------- action.yml | 1 - scripts/outputs.ps1 | 6 ------ 3 files changed, 3 insertions(+), 30 deletions(-) delete mode 100644 scripts/outputs.ps1 diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 9e5f508..e09255b 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -63,36 +63,16 @@ jobs: Set-GitHubEnvironmentVariable -Name 'OCTOCAT' -Value $cat Set-GitHubOutput -Name 'WISECAT' -Value $cat Set-GitHubOutput -Name 'Zen' -Value $zen - - "ZEN=$zen" >> $env:GITHUB_OUTPUT - 'WISECAT2<> $env:GITHUB_OUTPUT - $cat >> $env:GITHUB_OUTPUT - 'EOF' >> $env:GITHUB_OUTPUT - Set-GitHubStepSummary -Summary $cat - - name: test - id: test2 - shell: pwsh - run: | - Get-ChildItem env: | Format-Table -AutoSize - - - name: Action-Test-Env - uses: ./ - with: - Script: | - $env:OCTOCAT - - name: Action-Test-Output uses: ./ env: - result: ${{ steps.test.outputs.WISECAT }} + result: ${{ steps.test.outputs.result }} with: Script: | - "Wisecat" - $env:WISECAT - "Zen" - $env:ZEN + "result" + $env:result # ActionTestWithoutToken: # name: Action-Test - [WithoutToken] diff --git a/action.yml b/action.yml index abcd75b..610a3f9 100644 --- a/action.yml +++ b/action.yml @@ -63,4 +63,3 @@ runs: # GitHub-Script . "${{ github.action_path }}\scripts\main.ps1" ${{ inputs.Script }} - . "${{ github.action_path }}\scripts\outputs.ps1" diff --git a/scripts/outputs.ps1 b/scripts/outputs.ps1 deleted file mode 100644 index fde761b..0000000 --- a/scripts/outputs.ps1 +++ /dev/null @@ -1,6 +0,0 @@ - -Get-Content -Path $env:GITHUB_OUTPUT -# $outputs = Get-GitHubOutput -Path $env:GITHUB_OUTPUT -# $outputs -# $env:PSMODULE_GITHUB_SCRIPT = $false -# Set-GitHubOutput -Name 'result' -Value $outputs.result From 16330f1d15132ebf4d40b4acfe13786bb152e175 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 20:49:47 +0100 Subject: [PATCH 33/38] Update Action-Test workflow to parse JSON output and access specific properties --- .github/workflows/Action-Test.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index e09255b..18f357d 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -72,7 +72,9 @@ jobs: with: Script: | "result" - $env:result + $result = $env:result | ConvertFrom-Json + $result.WISECAT + $result.Zen # ActionTestWithoutToken: # name: Action-Test - [WithoutToken] From 659aa16b0ce6e4b3c097b2bf5a990141ac930325 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 20:56:02 +0100 Subject: [PATCH 34/38] Refactor Action-Test workflow to rename job and streamline output summary handling --- .github/workflows/Action-Test.yml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 18f357d..8964239 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -63,18 +63,14 @@ jobs: Set-GitHubEnvironmentVariable -Name 'OCTOCAT' -Value $cat Set-GitHubOutput -Name 'WISECAT' -Value $cat Set-GitHubOutput -Name 'Zen' -Value $zen - Set-GitHubStepSummary -Summary $cat - - name: Action-Test-Output - uses: ./ + - name: Run-test + shell: pwsh env: result: ${{ steps.test.outputs.result }} - with: - Script: | - "result" - $result = $env:result | ConvertFrom-Json - $result.WISECAT - $result.Zen + run: | + $result = $env:result | ConvertFrom-Json + Set-GitHubStepSummary -Summary $result.WISECAT # ActionTestWithoutToken: # name: Action-Test - [WithoutToken] From 162f9fb90512ddf7a8dcc210c6566cb59d54dd6f Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 21:00:46 +0100 Subject: [PATCH 35/38] test --- .github/workflows/Action-Test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 8964239..ed05d9e 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -71,6 +71,7 @@ jobs: run: | $result = $env:result | ConvertFrom-Json Set-GitHubStepSummary -Summary $result.WISECAT + Write-GitHubNotice -Message $result.Zen -Title 'GitHub Zen' # ActionTestWithoutToken: # name: Action-Test - [WithoutToken] From 6005b294272df2c1fadef22f41e9898eed250447 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 21:29:34 +0100 Subject: [PATCH 36/38] Update README.md to add outputs section and examples for using script results --- .github/workflows/Action-Test.yml | 1 - README.md | 31 +++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index ed05d9e..6e86035 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -56,7 +56,6 @@ jobs: uses: ./ id: test with: - Prerelease: true Script: | $cat = Get-GitHubOctocat $zen = Get-GitHubZen diff --git a/README.md b/README.md index b9b653a..1f13ce5 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,12 @@ For more information on the available functions and automatic loaded variables, | `Prerelease` | Allow prerelease versions if available | false | `'false'` | | `WorkingDirectory` | The working directory where the script will run from | false | `${{ github.workspace }}` | +### Outputs + +| Name | Description | +| - | - | +| `result` | The output of the script as a JSON object. To create outputs in `result` use [`Set-GitHubOutput`](https://psmodule.io/GitHub/Functions/Set-GitHubOutput/) | + ### Examples #### Example 1: Run a GitHub PowerShell script @@ -102,6 +108,31 @@ jobs: } ``` +#### Example 5: Using the outputs from the script + +Run a script that uses the GitHub PowerShell module and outputs the result. + +```yaml +- name: Run GitHub Script + uses: PSModule/GitHub-Script@v1 + id: outputs + with: + Script: | + $cat = Get-GitHubOctocat + $zen = Get-GitHubZen + Set-GitHubOutput -Name 'Octocat' -Value $cat + Set-GitHubOutput -Name 'Zen' -Value $zen + +- name: Use outputs + 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' +``` + ## Related projects - [actions/create-github-app-token](https://github.com/actions/create-github-app-token) -> Functionality will be brought into GitHub PowerShell module. From 5b7b7d0a75dcc589f9a3c13653e827df33c1de8b Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sun, 1 Dec 2024 21:43:27 +0100 Subject: [PATCH 37/38] Add Prerelease input to Action-Test workflow --- .github/workflows/Action-Test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 6e86035..ed05d9e 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -56,6 +56,7 @@ jobs: uses: ./ id: test with: + Prerelease: true Script: | $cat = Get-GitHubOctocat $zen = Get-GitHubZen From 582d185f6d72ed0dc7597a74eabb474c12134b42 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 2 Dec 2024 00:13:33 +0100 Subject: [PATCH 38/38] Refactor Action-Test workflow to enable job definitions and enhance README documentation for input descriptions and examples --- .github/workflows/Action-Test.yml | 212 +++++++++++++++--------------- README.md | 26 ++-- action.yml | 4 +- 3 files changed, 119 insertions(+), 123 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index ed05d9e..bbd12ae 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -17,32 +17,32 @@ permissions: pull-requests: read 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 - # } + 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] @@ -73,83 +73,83 @@ jobs: 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 - # } - # } + 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 + } + } diff --git a/README.md b/README.md index 1f13ce5..1c467a6 100644 --- a/README.md +++ b/README.md @@ -10,28 +10,27 @@ For more information on the available functions and automatic loaded variables, | Name | Description | Required | Default | | - | - | - | - | -| `Script` | The script to run | false | | -| `Token` | Log in using an Installation Access Token (IAT) | false | `${{ github.token }}` | -| `ClientID` | Log in using a GitHub App, using the App's Client ID and Private Key | false | | -| `PrivateKey` | Log in using a GitHub App, using the App's Client ID and Private Key | false | | -| `Debug` | Enable debug output | false | `'false'` | -| `Verbose` | Enable verbose output | false | `'false'` | +| `Script` | The script to run. Can be inline, multi-line or a path to a script file. | false | | +| `Token` | Log in using an Installation Access Token (IAT). | false | `${{ github.token }}` | +| `ClientID` | Log in using a GitHub App, using the App's Client ID and Private Key. | false | | +| `PrivateKey` | Log in using a GitHub App, using the App's Client ID and Private Key. | false | | +| `Debug` | Enable debug output. | false | `'false'` | +| `Verbose` | Enable verbose output. | false | `'false'` | | `Version` | Specifies the version of the GitHub module to be installed. The value must be an exact version. | false | | -| `Prerelease` | Allow prerelease versions if available | false | `'false'` | -| `WorkingDirectory` | The working directory where the script will run from | false | `${{ github.workspace }}` | +| `Prerelease` | Allow prerelease versions if available. | false | `'false'` | +| `WorkingDirectory` | The working directory where the script will run from. | false | `${{ github.workspace }}` | ### Outputs | Name | Description | | - | - | -| `result` | The output of the script as a JSON object. To create outputs in `result` use [`Set-GitHubOutput`](https://psmodule.io/GitHub/Functions/Set-GitHubOutput/) | +| `result` | The output of the script as a JSON object. To add outputs to `result`, use `Set-GitHubOutput`. | ### Examples #### Example 1: Run a GitHub PowerShell script -Run a script that uses the GitHub PowerShell module. -This example runs an authenticated script using the `GITHUB_TOKEN` and gets the GitHub Zen message. +Run a script (`scripts/main.ps1`) that uses the GitHub PowerShell module, authenticated using the `GITHUB_TOKEN`. ```yaml jobs: @@ -41,10 +40,7 @@ jobs: - name: Run script uses: PSModule/GitHub-Script@v1 with: - Script: | - LogGroup "Get-GitHubZen" { - Get-GitHubZen - } + Script: "scripts/main.ps1" ``` #### Example 2: Run a GitHub PowerShell script without a token diff --git a/action.yml b/action.yml index 610a3f9..26a4163 100644 --- a/action.yml +++ b/action.yml @@ -7,7 +7,7 @@ branding: inputs: Script: - description: The script to run. + description: The script to run. Can be inline, multi-line or a path to a script file. required: false Token: description: Log in using an Installation Access Token (IAT). @@ -41,7 +41,7 @@ inputs: outputs: result: - description: The output of the script. + description: The output of the script as a JSON object. To add outputs to `result`, use `Set-GitHubOutput`. value: ${{ steps.RunGitGubScript.outputs.result }} runs: