diff --git a/.github/workflows/Action-Test.yml b/.github/workflows/Action-Test.yml index 3995cf9..bab8397 100644 --- a/.github/workflows/Action-Test.yml +++ b/.github/workflows/Action-Test.yml @@ -56,8 +56,7 @@ jobs: uses: ./ with: Verbose: true - Version: 0.3.118 - Token: ${{ github.token }} + Version: 0.8.4 Script: | LogGroup "Get-GitHubZen" { Get-GitHubZen @@ -78,7 +77,6 @@ jobs: - name: Action-Test 1 uses: ./ with: - Token: ${{ github.token }} Script: | LogGroup "Get-GitHubZen" { Get-GitHubZen @@ -87,7 +85,6 @@ jobs: - name: Action-Test 2 uses: ./ with: - Token: ${{ github.token }} Script: | LogGroup "Get-GitHubOctocat" { Get-GitHubOctocat diff --git a/action.yml b/action.yml index a6d86d2..d7a6a8f 100644 --- a/action.yml +++ b/action.yml @@ -48,5 +48,4 @@ runs: run: | # GitHub-Script . "${{ github.action_path }}\scripts\main.ps1" - ${{ inputs.Script }} diff --git a/scripts/main.ps1 b/scripts/main.ps1 index 8567f7e..11e5abf 100644 --- a/scripts/main.ps1 +++ b/scripts/main.ps1 @@ -8,17 +8,12 @@ if ($env:GITHUB_ACTION_INPUT_Verbose -eq 'true') { $VerbosePreference = 'Continue' } -Install-PSResource -Name 'Store' -Version 0.2.2 -Repository PSGallery -TrustRepository +'::group::Setting up GitHub PowerShell module' $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" @@ -51,3 +46,17 @@ if (-not $alreadyImported) { Write-Verbose "Importing module: $Name" Import-Module -Name $Name } +'::endgroup::' + +LogGroup 'Connect-Github' { + if (-not [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_Token)) { + Write-Verbose "Setting GITHUB_TOKEN to provided input 'Token'" + Connect-Github -Token $env:GITHUB_ACTION_INPUT_Token + } elseif (-not [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_ClientID) -and -not [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_PrivateKey)) { + Write-Verbose "Setting ClientID and PEM to provided inputs 'ClientID' and 'PEM'" + Connect-Github -ClientID $env:GITHUB_ACTION_INPUT_ClientID -PrivateKey $env:GITHUB_ACTION_INPUT_PrivateKey + } elseif (-not [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_JWT)) { + Write-Verbose "Setting JWT to provided input 'JWT'" + Connect-Github -JWT $env:GITHUB_ACTION_INPUT_JWT + } +}