forked from jpogran/PuppetDscBuilder
-
Notifications
You must be signed in to change notification settings - Fork 12
110 lines (91 loc) · 3.32 KB
/
puppetize.yml
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
name: "puppetize"
on:
schedule:
- cron: "0 6 1,15 * *"
workflow_dispatch:
inputs:
module_name:
description: |
The name of the PowerShell module as it appears on the PowerShell Gallery.
required: false
env:
module_cache: PSFramework, PSDscResources, powershell-yaml
jobs:
setup:
name: "setup"
runs-on: "windows-latest"
outputs:
module: ${{ steps.setup_matrix.outputs.module }}
steps:
- name: "checkout"
uses: "actions/checkout@v3"
- name: "install modules"
uses: potatoqualitee/[email protected]
with:
shell: powershell
modules-to-cache: ${{ env.module_cache }}
- name: "setup matrix"
id: "setup_matrix"
shell: powershell
run: |
Import-Module -Name PSDesiredStateConfiguration -Force
Install-Module -Name Puppet.Dsc -Force
Import-Module -Name ./src/BuildMatrix/BuildMatrix.psd1 -Force
$ModuleData = $ENV:MODULE_NAME
# if no module name is provided to the workflow, get the top 50 downloaded DSC modules from the forge
if (!$ModuleData) {
# Get the top 50 downloaded DSC modules from the forge
$response = Invoke-WebRequest -URI https://forgeapi.puppet.com/v3/modules?owner=dsc`&limit=50`&endorsements=approved`&sort_by=downloads -Method Get -UseBasicParsing
$parsed = $response.Content | ConvertFrom-Json
$fileName = "./dsc_resources.yml"
# Add the module to the dsc_resource.yml if it doesn't exist
ForEach ($Module in $parsed.results.name) {
$module_name_exists = Select-String -Quiet -Pattern $Module -Path $fileName
if (-not $module_name_exists)
{
Add-Content -Path $fileName -Value " - name: $Module"
}
}
$ModuleData = Get-ModuleData -Path $fileName -UnPuppetizedOnly
}
$ModuleData | ConvertTo-BuildMatrix | Set-BuildMatrix
env:
MODULE_NAME: ${{ github.event.inputs.module_name }}
puppetize:
runs-on: "windows-latest"
defaults:
run:
shell: powershell
needs: "setup"
strategy:
fail-fast: false
matrix:
module: ${{ fromJson(needs.setup.outputs.module) }}
steps:
- name: "checkout"
uses: "actions/checkout@v3"
- name: "install required modules"
uses: potatoqualitee/[email protected]
with:
shell: powershell
modules-to-cache: ${{ env.module_cache }}
- name: Install PDK
uses: ./.github/actions/install-pdk
- name: Configure WinRM
uses: ./.github/actions/configure-winrm
- name: "publish module"
env:
FORGE_TOKEN: ${{ secrets.FORGE_API_TOKEN }}
run: |
Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
refreshenv
Import-Module -Name PSDesiredStateConfiguration -Force
Install-Module -Name Puppet.Dsc -Force
$null = Get-Command PDK, Publish-NewDscModuleVersion
$PublishParameters = @{
ForgeNameSpace = 'dsc'
Name = '${{ matrix.module }}'
OnlyNewer = $true
MaxBuildCount = 1
}
Publish-NewDscModuleVersion @PublishParameters -Verbose