Skip to content

Commit 6485cb7

Browse files
authored
Switching to us of GitHubActions module (#4)
* removing local lib * switching to module * no need for local lib anymore * Update ci.yml * Removing lib-related docs since these are now moved to PS Module: * checkout the docs at the [module GitHub](https://github.com/ebekker/pwsh-github-action-tools/blob/master/docs/GitHubActions/README.md). * upgrading dependencies to latest, removing some defunct stuff * updating reference to the module and the related docs * updating name to better reflect module changes
1 parent b19583a commit 6485cb7

27 files changed

+741
-1152
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,16 @@ jobs:
1919
- name: pester tests
2020
shell: pwsh
2121
run: |
22-
if (-not (Get-Module -ListAvailable Pester)) {
23-
Install-Module Pester -Force
22+
$neededModules = @(
23+
'Pester'
24+
'GitHubActions'
25+
)
26+
$neededModules | % {
27+
if (-not (Get-Module -ListAvailable $_)) {
28+
Install-Module $_ -Force
29+
}
2430
}
25-
./tests/ActionCore_tests.ps1
31+
./tests/GitHubActions_tests.ps1
2632
2733
# - name: bundle distributable components
2834
# shell: pwsh
@@ -37,7 +43,6 @@ jobs:
3743
run: |
3844
mkdir ./dist
3945
Copy-Item ./_init ./dist/ -Recurse
40-
Copy-Item ./lib ./dist/ -Recurse
4146
Copy-Item ./SAMPLE-* ./dist/
4247
Copy-Item ./LICENSE ./dist/
4348
Copy-Item ./README.md ./dist/
@@ -51,8 +56,7 @@ jobs:
5156
path: ./dist
5257

5358
publish:
54-
runs-on: ubuntu-16.04
55-
#runs-on: ubuntu-latest
59+
runs-on: ubuntu-latest
5660
needs: build
5761
if: github.event_name == 'release'
5862
steps:

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,3 +328,8 @@ ASALocalRun/
328328

329329
# MFractors (Xamarin productivity tool) working folder
330330
.mfractor/
331+
332+
333+
## Standard Ignores
334+
_IGNORE/
335+
_TMP/

README.md

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ Base support for implementing GitHub Actions in PowerShell Core
55

66
[![GitHub Workflow - CI](https://github.com/ebekker/pwsh-github-action-base/workflows/CI/badge.svg)](https://github.com/ebekker/pwsh-github-action-base/actions?workflow=CI)
77
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/ebekker/pwsh-github-action-base)](https://github.com/ebekker/pwsh-github-action-base/releases/latest/download/pwsh-github-action-base-dist.zip)
8-
[![docs for lib/ActionsCore](https://img.shields.io/badge/docs-lib/ActionsCore-blueviolet)](docs/README.md)
98

109
---
1110

@@ -18,16 +17,18 @@ The [distribution](https://github.com/ebekker/pwsh-github-action-base/releases/l
1817

1918
* **[`_init/index.js`](_init/index.js)** -
2019
The entry point into invoking the Action.
21-
* **[`lib/ActionsCore.ps1`](lib/ActionsCore.ps1)** -
22-
A collection of cmdlets that support interfacing to the
23-
Actions/Workflow environment for input, output and messaging.
2420
* **[`SAMPLE-action.ps1`](SAMPLE-action.ps1)** -
2521
A sample script implementing a simple Action script demonstrating some
2622
of the features made available from the Core library.
2723
* **[`SAMPLE-action.yml`](SAMPLE-action.yml)** -
2824
A sample Action metadata file that describes various attributes such as a
2925
description, licensing, branding and formal input and output values.
3026

27+
Additionally, the sample Action shows how to make use of the
28+
[GitHubActions module](https://www.powershellgallery.com/packages/GitHubActions)
29+
to get access to the GH Actions/Workflow environment for input, output
30+
and messaging. More details can be found [below](#optional-support-module)
31+
3132
## Required Components
3233

3334
### `action.ps1` - The PowerShell Entry Point
@@ -43,25 +44,29 @@ the GitHub API.
4344

4445
### `action.yml` - The Action Metadata
4546

46-
As per the GitHub Actions mechanism, you must provide a [metadata file](https://help.github.com/en/articles/metadata-syntax-for-github-actions) that describes
47-
various attributes about your Action, including any formal inputs and outputs.
48-
You use this metadata file to enumerate any _required_ inputs that must be
49-
provided by a Workflow definition.
47+
As per the GitHub Actions mechanism, you must provide a
48+
[metadata file](https://help.github.com/en/articles/metadata-syntax-for-github-actions)
49+
that describes various attributes about your Action, including any formal inputs
50+
and outputs. You use this metadata file to enumerate any _required_ inputs that
51+
must be provided by a Workflow definition.
5052

51-
##### `runs` Entry Point Attribute
53+
#### `runs` Entry Point Attribute
5254

5355
The most important attribute in this file for our purposes is the `runs`
5456
setting which has two child settings, `using` and `main`. This attribute
55-
indicates what is the [_type_](https://help.github.com/en/articles/about-actions#types-of-actions) of your Action and how to run it.
57+
indicates what is the
58+
[_type_](https://help.github.com/en/articles/about-actions#types-of-actions)
59+
of your Action and how to run it.
5660

5761
There are two main types of Actions, one based on Docker containers and
5862
one based on JavaScript (NodeJS). While Docker Actions give you the ability
5963
to define and _carry_ the entire runtime with you, they are slower to start
6064
and limited to only executing in Linux environments.
6165

6266
JavaScript Actions however are simpler and more lightweight, and therefore
63-
quicker to start, and they can run on any of the supported platforms (Linux, Windows, MacOS). They also execute directly in the hosted virtual machine
64-
where the Workflow runs instead of a dedicated container.
67+
quicker to start, and they can run on any of the supported platforms
68+
(Linux, Windows, MacOS). They also execute directly in the hosted virtual
69+
machine where the Workflow runs instead of a dedicated container.
6570

6671
Because of these advantages, this repo hosts a solution that is based on
6772
JavaScript-type Actions. A stub JavaScript script is provided to bootstrap
@@ -99,15 +104,16 @@ The working directory is the same as at the start of the bootstrap
99104
script which is the root of the cloned repository of the Workflow
100105
in which the action is being invoked.
101106

102-
## Optional Support Library
107+
## Optional Support Module
103108

104-
In addition to the required components above, you may choose to make use
105-
of the **[`lib/ActionsCore.ps1`](lib/ActionsCore.ps1)** utility script that
106-
defines a number of cmdlets that help interact with the Worklfow/Action
107-
environment context in a more natural way for PowerShell scripts.
108-
These cmdlets are adaptations of the JavaScript Actions
109+
In addition to the required components above, you may choose to make use of the
110+
**[`GitHubActions` PowerShell module](https://www.powershellgallery.com/packages/GitHubActions)**
111+
utility script that defines a number of cmdlets that help interact with the
112+
Worklfow/Action environment context in a more natural way for PowerShell
113+
scripts. These cmdlets are adaptations of the JavaScript Actions
109114
[core package](https://github.com/actions/toolkit/tree/master/packages/core) provided in the
110115
[Actions Toolkit](https://github.com/actions/toolkit). See that package
111116
description for details about what it provides
112117

113-
For details about the counterpart cmdlets, go to the [docs](docs/README.md).
118+
For details about the counterpart cmdlets, go to the
119+
[docs](https://github.com/ebekker/pwsh-github-action-tools/blob/master/docs/GitHubActions/README.md).

SAMPLE-action.ps1

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,24 @@
44
## This is a sample GitHub Action script written in PowerShell Core.
55
## You can write your logic in PWSH to perform GitHub Actions.
66
##
7+
8+
79
## You interface with the Actions/Workflow system by interacting
8-
## with the environment. The `ActionsCore.ps1` library makes this
9-
## easier and more natural.
10-
##
10+
## with the environment. The `GitHubActions` module makes this
11+
## easier and more natural by wrapping up access to the Workflow
12+
## environment in PowerShell-friendly constructions and idioms
13+
if (-not (Get-Module -ListAvailable GitHubActions)) {
14+
## Make sure the GH Actions module is installed from the Gallery
15+
Install-Module GitHubActions -Force
16+
}
1117

1218
## Load up some common functionality for interacting
1319
## with the GitHub Actions/Workflow environment
14-
. ./lib/ActionsCore.ps1
20+
Import-Module GitHubActions
21+
22+
##
23+
## ***** Put your logic here *****
24+
##
1525

1626
## Pull in some inputs
1727
$salutation = Get-ActionInput salutation -Required

0 commit comments

Comments
 (0)