Skip to content

Commit 3d7cea4

Browse files
Initial version
1 parent efcee9c commit 3d7cea4

File tree

10 files changed

+271
-1
lines changed

10 files changed

+271
-1
lines changed

.github/linters/.markdown-lint.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
###########################
2+
## Markdown Linter rules ##
3+
###########################
4+
5+
# Linter rules doc:
6+
# - https://github.com/DavidAnson/markdownlint
7+
8+
###############
9+
# Rules by id #
10+
###############
11+
MD004: false # Unordered list style
12+
MD007:
13+
indent: 2 # Unordered list indentation
14+
MD013:
15+
line_length: 808 # Line length
16+
MD026:
17+
punctuation: ".,;:!。,;:" # List of not allowed
18+
MD029: false # Ordered list item prefix
19+
MD033: false # Allow inline HTML
20+
MD036: false # Emphasis used instead of a heading
21+
22+
#################
23+
# Rules by tags #
24+
#################
25+
blank_lines: false # Error on blank lines

.github/release.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes#configuring-automatically-generated-release-notes
2+
3+
changelog:
4+
categories:
5+
- title: Breaking Changes
6+
labels:
7+
- Major
8+
- Breaking
9+
- title: New Features
10+
labels:
11+
- Minor
12+
- Feature
13+
- Improvement
14+
- Enhancement
15+
- title: Other Changes
16+
labels:
17+
- '*'

.github/workflows/Action-Test.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Action-Test
2+
3+
run-name: "Action-Test - [${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}] by @${{ github.actor }}"
4+
5+
on: [pull_request]
6+
7+
jobs:
8+
ActionTestDefault:
9+
name: Action-Test - [Default]
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repo
13+
uses: actions/checkout@v4
14+
15+
- name: Action-Test
16+
uses: ./

.github/workflows/Auto-Release.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Auto-Release
2+
3+
run-name: "Auto-Release - [${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}] by @${{ github.actor }}"
4+
5+
on:
6+
pull_request_target:
7+
branches:
8+
- main
9+
types:
10+
- closed
11+
- opened
12+
- reopened
13+
- synchronize
14+
- labeled
15+
16+
concurrency:
17+
group: ${{ github.workflow }}
18+
19+
permissions:
20+
contents: write
21+
pull-requests: write
22+
23+
jobs:
24+
Auto-Release:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout Code
28+
uses: actions/checkout@v4
29+
30+
- name: Auto-Release
31+
uses: PSModule/Auto-Release@v1
32+
env:
33+
GITHUB_TOKEN: ${{ github.token }} # Used for GitHub CLI authentication
34+
with:
35+
IncrementalPrerelease: false

.github/workflows/Linter.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Linter
2+
3+
run-name: "Linter - [${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}] by @${{ github.actor }}"
4+
5+
on: [pull_request]
6+
7+
jobs:
8+
Lint:
9+
name: Lint code base
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repo
13+
uses: actions/checkout@v4
14+
15+
- name: Lint code base
16+
uses: github/super-linter@latest
17+
env:
18+
GITHUB_TOKEN: ${{ github.token }}

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## Ignore Visual Studio Code temporary files, build results, and
2+
## files generated by popular Visual Studio Code add-ons.
3+
##
4+
## Get latest from https://github.com/github/gitignore/blob/master/Global/VisualStudioCode.gitignore
5+
.vscode/*
6+
!.vscode/settings.json
7+
!.vscode/extensions.json
8+
*.code-workspace
9+
10+
# Local History for Visual Studio Code
11+
.history/

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 PSModule
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,70 @@
11
# Initialize-PSModule
2-
An action that is used to prepare the runner for PSModule framework
2+
3+
An action that is used to prepare the runner for PSModule framework.
4+
5+
## Specifications and practices
6+
7+
Initiate-PSModule follows:
8+
9+
- [SemVer 2.0.0 specifications](https://semver.org)
10+
- [GitHub Flow specifications](https://docs.github.com/en/get-started/using-github/github-flow)
11+
- [Continiuous Delivery practices](https://en.wikipedia.org/wiki/Continuous_delivery)
12+
13+
... and supports the following practices in the PSModule framework:
14+
15+
- [DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself)
16+
17+
## How it works
18+
19+
The Initialize-PSModule action will prepare the runner for the PSModule framework by installing the following dependencies:
20+
21+
| Module | Description |
22+
| --- | --- |
23+
| Utilities | Used by all actions, contains common function and classes such as logging, grouping and the [PSSemVer] class. |
24+
| powershell-yaml | Used to parse and serialize YAML files, typically for reading configuration files. |
25+
| Pester | Used for testing PowerShell code. |
26+
| PSScriptAnalyzer | Used to lint and format PowerShell code. |
27+
| platyPS | Used to generate Markdown documentation from PowerShell code. |
28+
29+
It also makes the following environment variables available to the runner:
30+
31+
| Variable | Description |
32+
| --- | --- |
33+
| GITHUB_REPOSITORY_NAME | Contains the name of the repository, used to automatically act as the name of the module. |
34+
35+
## Usage
36+
37+
The action can be configured using the following settings:
38+
39+
| Name | Description | Default | Required |
40+
| --- | --- | --- | --- |
41+
| | | | |
42+
43+
### Configuration file
44+
45+
There are no configuration settings for the Initialize-PSModule action.
46+
47+
## Example
48+
49+
The action can be used in a workflow to prepare the runner for the PSModule framework by adding it at the start of the workflow.
50+
51+
```yaml
52+
name: Process-PSModule
53+
54+
on: [push]
55+
56+
jobs:
57+
Process-PSModule:
58+
name: Process module
59+
runs-on: ubuntu-latest
60+
steps:
61+
- name: Checkout Code
62+
uses: actions/checkout@v4
63+
64+
- name: Initialize environment
65+
uses: PSModule/Initialize-PSModule@main
66+
```
67+
68+
## Permissions
69+
70+
The action does not require any permissions.

action.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Initialize-PSModule
2+
description: Prepare runner for the PSModule framework
3+
branding:
4+
icon: activity
5+
color: blue
6+
7+
runs:
8+
using: composite
9+
steps:
10+
- name: Run Initialize-PSModule
11+
shell: pwsh
12+
run: |
13+
# Initialize-PSModule
14+
Write-Host '::group::Loading modules'
15+
Install-PSResource -Name 'Utilities' -TrustRepository -Verbose
16+
17+
. "$env:GITHUB_ACTION_PATH\scripts\main.ps1" -Verbose

scripts/main.ps1

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#REQUIRES -Modules Utilities
2+
3+
[CmdletBinding()]
4+
param()
5+
6+
Install-PSResource -Name 'powershell-yaml', 'Pester', 'PSScriptAnalyzer', 'platyPS' -TrustRepository -Verbose
7+
Stop-LogGroup
8+
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
33+
}
34+
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 'Files and Folders'
41+
Write-Verbose (Get-ChildItem -Path $env:GITHUB_WORKSPACE -Recurse | Select-Object -ExpandProperty FullName | Sort-Object | Out-String)
42+
Stop-LogGroup

0 commit comments

Comments
 (0)