From 2e134522c1e94354020a3ce41b4e0b0fd0dda043 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Thu, 7 Nov 2024 23:32:04 +0100 Subject: [PATCH 1/6] Add nightly run --- .github/workflows/Action-Test.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 4d664bc..0b25eca 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -2,7 +2,11 @@ name: Action-Test run-name: "Action-Test - [${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}] by @${{ github.actor }}" -on: [pull_request] +on: + workflow_dispatch: + pull_request: + schedule: + - cron: '0 0 * * *' concurrency: group: ${{ github.workflow }}-${{ github.ref }} From b1738e8102a584eeecf55d4b63a85259f9cf75f0 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 8 Nov 2024 00:13:21 +0100 Subject: [PATCH 2/6] test --- .github/workflows/Action-Test.yml | 1 - action.yml | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 0b25eca..77d41c1 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -90,7 +90,6 @@ jobs: Get-GitHubOctocat } - ActionTestWithVersion: name: Action-Test - [WithVersion] runs-on: ubuntu-latest diff --git a/action.yml b/action.yml index 8ba5901..7999fd8 100644 --- a/action.yml +++ b/action.yml @@ -12,6 +12,7 @@ inputs: Token: description: The GitHub token to use. This will override the default behavior of using the `GITHUB_TOKEN` environment variable. required: false + default: ${{ github.token }} Debug: description: Enable debug output. required: false From 630055ed72ddcfa404437d7f5ce3fcc35ae179f7 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Fri, 8 Nov 2024 00:21:56 +0100 Subject: [PATCH 3/6] Cleanup tests --- .github/workflows/Action-Test.yml | 53 ------------------------------- 1 file changed, 53 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 77d41c1..4e87ade 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -39,57 +39,11 @@ jobs: - name: Action-Test uses: ./ with: - Verbose: true Script: | LogGroup "My group" { "This is a group" } - ActionTestWithGitHubToken: - name: Action-Test - [WithGitHubToken] - runs-on: ubuntu-latest - env: - GITHUB_TOKEN: ${{ github.token }} - 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: - Verbose: true - Script: | - LogGroup "Get-GitHubZen" { - Get-GitHubZen - } - - LogGroup "Get-GitHubOctocat" { - Get-GitHubOctocat - } - - ActionTestWithToken: - name: Action-Test - [WithToken] - 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: ${{ github.token }} - Verbose: true - Script: | - LogGroup "Get-GitHubZen" { - Get-GitHubZen - } - - LogGroup "Get-GitHubOctocat" { - Get-GitHubOctocat - } - ActionTestWithVersion: name: Action-Test - [WithVersion] runs-on: ubuntu-latest @@ -101,7 +55,6 @@ jobs: - name: Action-Test uses: ./ with: - Token: ${{ github.token }} Verbose: true Version: 0.3.118 Script: | @@ -124,8 +77,6 @@ jobs: - name: Action-Test 1 uses: ./ with: - Token: ${{ github.token }} - Verbose: true Script: | LogGroup "Get-GitHubZen" { Get-GitHubZen @@ -134,8 +85,6 @@ jobs: - name: Action-Test 2 uses: ./ with: - Token: ${{ github.token }} - Verbose: true Script: | LogGroup "Get-GitHubOctocat" { Get-GitHubOctocat @@ -144,8 +93,6 @@ jobs: - name: Action-Test 3 uses: ./ with: - Token: ${{ github.token }} - Verbose: true Script: | LogGroup "Get-GitHubRateLimit" { Get-GitHubRateLimit From 5fce944665f4ad0d8502a66861eff6e069de3817 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 9 Nov 2024 10:48:12 +0100 Subject: [PATCH 4/6] Outofscope --- action.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/action.yml b/action.yml index 7999fd8..8ba5901 100644 --- a/action.yml +++ b/action.yml @@ -12,7 +12,6 @@ inputs: Token: description: The GitHub token to use. This will override the default behavior of using the `GITHUB_TOKEN` environment variable. required: false - default: ${{ github.token }} Debug: description: Enable debug output. required: false From 6d3e7c2a975848a1782c6d05e2afb8d72631c5bc Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 9 Nov 2024 10:50:17 +0100 Subject: [PATCH 5/6] Add the token outside --- .github/workflows/Action-Test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 4e87ade..3995cf9 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -57,6 +57,7 @@ jobs: with: Verbose: true Version: 0.3.118 + Token: ${{ github.token }} Script: | LogGroup "Get-GitHubZen" { Get-GitHubZen @@ -77,6 +78,7 @@ jobs: - name: Action-Test 1 uses: ./ with: + Token: ${{ github.token }} Script: | LogGroup "Get-GitHubZen" { Get-GitHubZen @@ -85,6 +87,7 @@ jobs: - name: Action-Test 2 uses: ./ with: + Token: ${{ github.token }} Script: | LogGroup "Get-GitHubOctocat" { Get-GitHubOctocat From 1bc02cb41faeba6a4d59be88bd9c1c848752438c Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Sat, 9 Nov 2024 11:03:24 +0100 Subject: [PATCH 6/6] Fix --- action.yml | 9 ++------- scripts/main.ps1 | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/action.yml b/action.yml index 8ba5901..a6d86d2 100644 --- a/action.yml +++ b/action.yml @@ -10,8 +10,9 @@ inputs: description: The script to run. required: false Token: - description: The GitHub token to use. This will override the default behavior of using the `GITHUB_TOKEN` environment variable. + description: The access token to use. required: false + default: ${{ github.token }} Debug: description: Enable debug output. required: false @@ -46,12 +47,6 @@ runs: GITHUB_ACTION_INPUT_Prerelease: ${{ inputs.Prerelease }} run: | # GitHub-Script - if ($env:GITHUB_ACTION_INPUT_Debug -eq 'true') { - $DebugPreference = 'Continue' - } - if ($env:GITHUB_ACTION_INPUT_Verbose -eq 'true') { - $VerbosePreference = 'Continue' - } . "${{ github.action_path }}\scripts\main.ps1" ${{ inputs.Script }} diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 1a7b9e6..8567f7e 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -1,6 +1,15 @@ [CmdletBinding()] param() +if ($env:GITHUB_ACTION_INPUT_Debug -eq 'true') { + $DebugPreference = 'Continue' +} +if ($env:GITHUB_ACTION_INPUT_Verbose -eq 'true') { + $VerbosePreference = 'Continue' +} + +Install-PSResource -Name 'Store' -Version 0.2.2 -Repository PSGallery -TrustRepository + $Name = 'GitHub' $Version = [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_Version) ? $null : $env:GITHUB_ACTION_INPUT_Version $Prerelease = $env:GITHUB_ACTION_INPUT_Prerelease -eq 'true' @@ -16,10 +25,10 @@ if ($Version) { $alreadyInstalled = $alreadyInstalled | Where-Object Version -EQ $Version } if ($Prerelease) { - Write-Verbose "Filtering by prerelease" + Write-Verbose 'Filtering by prerelease' $alreadyInstalled = $alreadyInstalled | Where-Object Prerelease -EQ $Prerelease } -Write-Verbose "Already installed:" +Write-Verbose 'Already installed:' Write-Verbose ($alreadyInstalled | Format-Table | Out-String) if (-not $alreadyInstalled) { Write-Verbose "Installing module. Name: [$Name], Version: [$Version], Prerelease: [$Prerelease]" @@ -36,7 +45,7 @@ if (-not $alreadyInstalled) { } $alreadyImported = Get-Module -Name $Name -Write-Verbose "Already imported:" +Write-Verbose 'Already imported:' Write-Verbose ($alreadyImported | Format-Table | Out-String) if (-not $alreadyImported) { Write-Verbose "Importing module: $Name"