Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 6 additions & 53 deletions .github/workflows/Action-Test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -35,58 +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
Expand All @@ -98,9 +55,9 @@ jobs:
- name: Action-Test
uses: ./
with:
Token: ${{ github.token }}
Verbose: true
Version: 0.3.118
Token: ${{ github.token }}
Script: |
LogGroup "Get-GitHubZen" {
Get-GitHubZen
Expand All @@ -122,7 +79,6 @@ jobs:
uses: ./
with:
Token: ${{ github.token }}
Verbose: true
Script: |
LogGroup "Get-GitHubZen" {
Get-GitHubZen
Expand All @@ -132,7 +88,6 @@ jobs:
uses: ./
with:
Token: ${{ github.token }}
Verbose: true
Script: |
LogGroup "Get-GitHubOctocat" {
Get-GitHubOctocat
Expand All @@ -141,8 +96,6 @@ jobs:
- name: Action-Test 3
uses: ./
with:
Token: ${{ github.token }}
Verbose: true
Script: |
LogGroup "Get-GitHubRateLimit" {
Get-GitHubRateLimit
Expand Down
9 changes: 2 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
15 changes: 12 additions & 3 deletions scripts/main.ps1
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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]"
Expand All @@ -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"
Expand Down