-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSAMPLE-action.ps1
48 lines (37 loc) · 1.42 KB
/
SAMPLE-action.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env pwsh
##
## This is a sample GitHub Action script written in PowerShell Core.
## You can write your logic in PWSH to perform GitHub Actions.
##
## You interface with the Actions/Workflow system by interacting
## with the environment. The `GitHubActions` module makes this
## easier and more natural by wrapping up access to the Workflow
## environment in PowerShell-friendly constructions and idioms
if (-not (Get-Module -ListAvailable GitHubActions)) {
## Make sure the GH Actions module is installed from the Gallery
Install-Module GitHubActions -Force
}
## Load up some common functionality for interacting
## with the GitHub Actions/Workflow environment
Import-Module GitHubActions
##
## ***** Put your logic here *****
##
## Pull in some inputs
$salutation = Get-ActionInput salutation -Required
$audience = Get-ActionInput audience
if (-not $salutation) {
## We actually specified this input as *required* above so
## this should never execute, but here is an example value
$salutation = "Hello"
}
if (-not $audience) {
$audience = "World"
}
$greeting = "$($salutation) $($audience)!"
## Persist the greeting in the environment for all subsequent steps
Set-ActionVariable -Name build_greeting -Value greeting
## Expose the greeting as an output value of this step instance
Set-ActionOutput -Name greeting -Value $greeting
## Write it out to the log for good measure
Write-ActionInfo $greeting