Skip to content

Commit 1262ae1

Browse files
🩹 [Patch]: Move to GitHub-Script action (#19)
## Description - Move to `GitHub-Script` action ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [x] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas
1 parent 7d19647 commit 1262ae1

File tree

4 files changed

+20
-129
lines changed

4 files changed

+20
-129
lines changed

.github/workflows/Action-Test.yml

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -11,64 +11,17 @@ concurrency:
1111
permissions: {}
1212

1313
jobs:
14-
ActionTestDefault:
14+
ActionTestBasic:
1515
strategy:
1616
fail-fast: false
1717
matrix:
1818
shell: [pwsh]
1919
os: [ubuntu-latest, macos-latest, windows-latest]
20-
include:
21-
- shell: powershell
22-
os: windows-latest
23-
name: Action-Test - [Default] - [${{ matrix.os }}@${{ matrix.shell }}]
20+
name: Action-Test - [Basic] - [${{ matrix.os }}]
2421
runs-on: ${{ matrix.os }}
2522
steps:
2623
- name: Checkout repo
2724
uses: actions/checkout@v4
2825

2926
- name: Action-Test
3027
uses: ./
31-
with:
32-
Shell: ${{ matrix.shell }}
33-
34-
ActionTestPrerelease:
35-
strategy:
36-
fail-fast: false
37-
matrix:
38-
shell: [pwsh]
39-
os: [ubuntu-latest, macos-latest, windows-latest]
40-
include:
41-
- shell: powershell
42-
os: windows-latest
43-
name: Action-Test - [Prerelease] - [${{ matrix.os }}@${{ matrix.shell }}]
44-
runs-on: ${{ matrix.os }}
45-
steps:
46-
- name: Checkout repo
47-
uses: actions/checkout@v4
48-
49-
- name: Action-Test
50-
uses: ./
51-
with:
52-
Shell: ${{ matrix.shell }}
53-
Prerelease: true
54-
55-
ActionTestVersion:
56-
strategy:
57-
fail-fast: false
58-
matrix:
59-
shell: [pwsh]
60-
os: [ubuntu-latest, macos-latest, windows-latest]
61-
include:
62-
- shell: powershell
63-
os: windows-latest
64-
name: Action-Test - [Version] - [${{ matrix.os }}@${{ matrix.shell }}]
65-
runs-on: ${{ matrix.os }}
66-
steps:
67-
- name: Checkout repo
68-
uses: actions/checkout@v4
69-
70-
- name: Action-Test
71-
uses: ./
72-
with:
73-
Shell: ${{ matrix.shell }}
74-
Version: '[0.1,0.2]'

.github/workflows/Linter.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ jobs:
2828
env:
2929
GITHUB_TOKEN: ${{ github.token }}
3030
VALIDATE_JSCPD: false
31+
VALIDATE_MARKDOWN_PRETTIER: false
32+
VALIDATE_YAML_PRETTIER: false

action.yml

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,12 @@ branding:
55
icon: loader
66
color: gray-dark
77

8-
inputs:
9-
Version:
10-
description: The version of the Utilities module to install.
11-
required: false
12-
Prerelease:
13-
description: Whether to install prerelease versions of the Utilities module.
14-
required: false
15-
default: 'false'
16-
Shell:
17-
description: The shell to use for running the tests.
18-
required: false
19-
default: pwsh
20-
218
runs:
229
using: composite
2310
steps:
24-
- name: Run Initialize-PSModule
25-
shell: ${{ inputs.Shell }}
26-
env:
27-
GITHUB_ACTION_INPUT_Version: ${{ inputs.Version }}
28-
GITHUB_ACTION_INPUT_Prerelease: ${{ inputs.Prerelease }}
29-
run: |
30-
# Initialize-PSModule
31-
Write-Host '::group::Loading modules'
32-
Install-Module -Name 'Microsoft.PowerShell.PSResourceGet' -Force -Verbose
33-
Import-Module -Name 'Microsoft.PowerShell.PSResourceGet' -Force -Verbose
34-
35-
$params = @{
36-
Name = 'Utilities'
37-
Repository = 'PSGallery'
38-
TrustRepository = $true
39-
PreRelease = $env:GITHUB_ACTION_INPUT_Prerelease -eq 'true'
40-
Verbose = $true
41-
}
42-
if (-not [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_Version)) {
43-
$params['Version'] = $env:GITHUB_ACTION_INPUT_Version
44-
}
45-
46-
Install-PSResource @params
47-
Import-Module -Name 'Utilities' -Force -Verbose
48-
Write-Host '::endgroup::'
49-
50-
. "$env:GITHUB_ACTION_PATH\scripts\main.ps1" -Verbose
11+
- name: Initialize-PSModule
12+
uses: PSModule/GitHub-Script@v1
13+
with:
14+
Script: |
15+
# Initialize-PSModule
16+
. "${{ github.action_path }}\scripts\main.ps1" -Verbose

scripts/main.ps1

Lines changed: 10 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,17 @@
1-
#REQUIRES -Modules Utilities
1+
#Requires -Modules GitHub
22

33
[CmdletBinding()]
44
param()
55

6-
Install-PSResource -Name 'powershell-yaml', 'PSSemVer', 'Pester', 'PSScriptAnalyzer', 'platyPS' -TrustRepository -Verbose
7-
Stop-LogGroup
6+
$requiredModules = 'Utilities', 'powershell-yaml', 'PSSemVer', 'Pester', 'PSScriptAnalyzer', 'platyPS'
87

9-
Start-LogGroup 'Loading helper scripts'
10-
Get-ChildItem -Path (Join-Path -Path $env:GITHUB_ACTION_PATH -ChildPath 'scripts\helpers') -Filter '*.ps1' -Recurse |
11-
ForEach-Object { Write-Verbose "[$($_.FullName)]"; . $_.FullName }
12-
Stop-LogGroup
13-
14-
Start-LogGroup 'Loading inputs'
15-
$env:GITHUB_REPOSITORY_NAME = $env:GITHUB_REPOSITORY -replace '.+/'
16-
Set-GitHubEnv -Name 'GITHUB_REPOSITORY_NAME' -Value $env:GITHUB_REPOSITORY_NAME
17-
Stop-LogGroup
18-
19-
Start-LogGroup 'PSVersionTable'
20-
Write-Verbose ($PSVersionTable | Format-Table -AutoSize | Out-String)
21-
Stop-LogGroup
22-
23-
Start-LogGroup 'Installed Modules - List'
24-
$modules = Get-PSResource | Sort-Object -Property Name
25-
Write-Verbose ($modules | Select-Object Name, Version, CompanyName, Author | Out-String)
26-
Stop-LogGroup
27-
28-
$modules.Name | Select-Object -Unique | ForEach-Object {
29-
$name = $_
30-
Start-LogGroup "Installed Modules - Details - [$name]"
31-
Write-Verbose ($modules | Where-Object Name -EQ $name | Select-Object * | Out-String)
32-
Stop-LogGroup
8+
$requiredModules | Sort-Object | ForEach-Object {
9+
$moduleName = $_
10+
LogGroup "Installing prerequisite: [$moduleName]" {
11+
Install-PSResource -Name $moduleName -TrustRepository -Repository PSGallery
12+
Write-Verbose (Get-PSResource -Name $moduleName | Select-Object * | Out-String)
13+
}
3314
}
3415

35-
Start-LogGroup 'Environment Variables'
36-
Write-Verbose (Get-ChildItem -Path env: | Select-Object -Property Name, Value |
37-
Sort-Object -Property Name | Format-Table -AutoSize -Wrap | Out-String)
38-
Stop-LogGroup
39-
40-
Start-LogGroup 'PowerShell Variables'
41-
Write-Verbose (Get-Variable | Select-Object -Property Name, Value |
42-
Sort-Object -Property Name | Format-Table -AutoSize -Wrap | Out-String)
43-
Stop-LogGroup
44-
45-
Start-LogGroup 'Files and Folders'
46-
Write-Verbose (Get-ChildItem -Path $env:GITHUB_WORKSPACE -Recurse | Select-Object -ExpandProperty FullName | Sort-Object | Out-String)
47-
Stop-LogGroup
16+
Get-PSResource -Name $requiredModules -Verbose:$false | Sort-Object -Property Name |
17+
Format-Table -Property Name, Version, Prerelease, Repository -AutoSize -Wrap

0 commit comments

Comments
 (0)