From 4470f82014b2ebf7459caa344e57c9cffa0a39ea Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 19 Aug 2024 17:52:03 +0200 Subject: [PATCH 1/2] Token = override of GITHUB_TOKEN --- action.yml | 2 +- scripts/main.ps1 | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index ef5dd60..4d5fb16 100644 --- a/action.yml +++ b/action.yml @@ -39,7 +39,7 @@ runs: shell: pwsh working-directory: ${{ inputs.WorkingDirectory }} env: - GITHUB_TOKEN: ${{ inputs.Token }} + GITHUB_ACTION_INPUT_Token: ${{ inputs.Token }} GITHUB_ACTION_INPUT_Debug: ${{ inputs.Debug }} GITHUB_ACTION_INPUT_Verbose: ${{ inputs.Verbose }} GITHUB_ACTION_INPUT_Version: ${{ inputs.Version }} diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 95b9876..1a7b9e6 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -5,6 +5,11 @@ $Name = 'GitHub' $Version = [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_Version) ? $null : $env:GITHUB_ACTION_INPUT_Version $Prerelease = $env:GITHUB_ACTION_INPUT_Prerelease -eq 'true' +if (-not [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_Token)) { + Write-Verbose "Setting GITHUB_TOKEN to provided input 'Token'" + $env:GITHUB_TOKEN = $env:GITHUB_ACTION_INPUT_Token +} + $alreadyInstalled = Get-InstalledPSResource -Name $Name -ErrorAction SilentlyContinue if ($Version) { Write-Verbose "Filtering by version: $Version" From 53e41138fb132495cb35544b88e742440748b644 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 19 Aug 2024 17:54:40 +0200 Subject: [PATCH 2/2] test --- .github/workflows/Action-Test.yml | 24 ++++++++++++++++++++++++ README.md | 2 +- action.yml | 2 +- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 7369f28..4d664bc 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -41,6 +41,29 @@ jobs: "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 @@ -63,6 +86,7 @@ jobs: Get-GitHubOctocat } + ActionTestWithVersion: name: Action-Test - [WithVersion] runs-on: ubuntu-latest diff --git a/README.md b/README.md index 8e27a18..df6f9c9 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ For more information on the available functions and automatic loaded variables, | Name | Description | Required | Default | | - | - | - | - | | `Script` | The script to run | false | | -| `Token` | The GitHub token to use | false | `${{ github.token }}` | +| `Token` | The GitHub token to use. This will override the default behavior of using the `GITHUB_TOKEN` environment variable. | false | `${{ github.token }}` | | `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 | | diff --git a/action.yml b/action.yml index 4d5fb16..8ba5901 100644 --- a/action.yml +++ b/action.yml @@ -10,7 +10,7 @@ inputs: description: The script to run. required: false Token: - description: The GitHub token to use. + description: The GitHub token to use. This will override the default behavior of using the `GITHUB_TOKEN` environment variable. required: false Debug: description: Enable debug output.