puppetize #6178
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |