A PowerShell module providing utilities for GitHub Actions and cloud infrastructure deployments.
Converts tokenized .bicepparam, .json and .tfvars files by replacing tokens with values from a provided map. Useful for managing a single configuration file across different environments.
$tokenMap = @{
name = 'test'
count = 1
enabled = $true
identity = $null
}
Convert-Token -InputFile 'params.bicepparam' -OutputFile 'expanded.bicepparam' -TokenMap $tokenMapusing 'test.bicep'
param name = '{{ name }}'
param count = '{{ count }}'
param enabled = '{{ enabled }}'
param identity = '{{ identity }}'using 'test.bicep'
param name = 'test'
param count = 1
param enabled = true
param identity = null$tokenMap = @{
name = 'test'
count = 1
enabled = $true
identity = $null
}
Convert-Token -InputFile 'params.tfvars' -OutputFile 'expanded.tfvars' -TokenMap $tokenMapname = "{{ name }}"
count = "{{ count }}"
enabled = "{{ enabled }}"
identity = "{{ identity }}"name = "test"
count = 1
enabled = true
identity = null$tokenMap = @{
name = 'test'
count = 1
enabled = $true
identity = $null
}
Convert-Token -InputFile 'params.json' -OutputFile 'expanded.json' -TokenMap $tokenMap{
"name": "{{ name }}",
"count": "{{ count }}",
"enabled": "{{ enabled }}",
"identity": "{{ identity }}"
}{
"name": "test",
"count": 1,
"enabled": true,
"identity": null
}$tokenMap = @{
name = 'test'
count = 1
enabled = $true
identity = $null
}
Convert-Token -InputFile 'params.psd1' -OutputFile 'expanded.psd1' -TokenMap $tokenMap@{
name = '{{ name }}'
count = '{{ count }}'
enabled = '{{ enabled }}'
identity = '{{ identity }}'
}@{
name = 'test'
count = 1
enabled = $true
identity = $null
}Sets GitHub Actions variables during workflow execution.
Environment variables can be set as follows:
Set-GhVariable -Name 'DEPLOY_ENV' -Value 'production'Output variables can be set as follows:
Set-GhVariable -Name 'DEPLOY_URL' -Value 'https://example.com' -IsOutputSecret variables can be set as follows:
Set-GhVariable -Name 'DEPLOY_SECRET' -Value 'supersecret' -IsSecretSet-GhVariable -Name 'DEPLOY_SECRET' -Value 'supersecret' -IsSecret -IsOutputNote: Secret variables are not available to subsequent jobs in a workflow.
Generates a random secure string.
New-RandomSecret -Length 32Returns a version for tagging infrastructure resources by looking at the git ref, latest tag or a default value provided
Tag from git ref:
Get-TagVersion -Ref 'refs/tags/v2.0.0'v2.0.0
Tag from latest git tag:
Get-TagVersion -Ref 'refs/heads/main'v2.0.1 *Assuming v2.0.1 is the latest git tag
Tag from default value:
Get-TagVersion -Ref 'refs/heads/main' -DefaultVersion 'v0.1.0-beta'v0.1.0-beta *Assuming no tag is found
The module includes Pester tests located in the tests directory. To run the tests:
Use the VS Code "Run Tests" task or:
Invoke-Build -File ./build.ps1 -Task testUse the VS Code "Build Locally" task or:
Invoke-Build -File ./build.ps1 -Task local_build- PowerShell 7
- GitHub Actions environment (for
Set-GhVariable)
Install-Module -Name GhCloudOps