-
-
Notifications
You must be signed in to change notification settings - Fork 1
72 lines (57 loc) · 1.95 KB
/
Copy pathdeploy_module_on_release.yml
File metadata and controls
72 lines (57 loc) · 1.95 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Deploy on Release Published
on:
workflow_dispatch:
release:
types: [published]
permissions:
contents: read
jobs:
deploy_to_powershellgallery:
runs-on: ubuntu-latest
environment: powershellgallery
steps:
- uses: actions/checkout@v3
- env:
EVENT_CONTEXT: ${{ toJSON(github.event) }}
run: |
echo $EVENT_CONTEXT
- name: Run test.ps1
shell: pwsh
run: |
$result = ./test.ps1 -ShowTestErrors
Write-Output $result
import-module ./tools/Test_Helper/
$passed = Test-Result -Result $result
if($passed)
{ "All test passed" | Write-Verbose -verbose ; exit 0 }
else
{ "Not all tests passed" | Write-Verbose -verbose ; exit 1 }
- name: deploy_ps1
shell: pwsh
env:
NUGETAPIKEY: ${{ secrets.NUGETAPIKEY }}
EVENT_REF: ${{ github.event.ref }}
RELEASE_TAG: ${{ github.event.release.tag_name }}
RELEASE_NAME: ${{ github.event.release.name }}
run: |
# Import required modules for deployment
import-module ./tools/Test_Helper/
Get-RequiredModule -Verbose | Import-RequiredModule -AllowPrerelease
# GET TAG NAME
## Ref definition. Branch or Tag
$env:EVENT_REF = $env:REF
If ([string]::IsNullOrEmpty($env:EVENT_REF)) {
# Release published trigger
$tag = $env:RELEASE_TAG
write-host -message "Release [$env:RELEASE_NAME] on tag [$tag]"
} else {
# Read Tag o Branch name
$tag = $env:EVENT_REF.Split('/')[2]
write-host "workflow_dispatch triggered on ref leaf [$tag]"
}
If([string]::IsNullorwhitespace($tag)) {
# Tag name is empty, exit
throw "Tag name is empty"
}
# DEPLOYMENT
./deploy.ps1 -VersionTag $tag -NugetApiKey $env:NUGETAPIKEY