Skip to content

brianwest/GhCloudOps

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

GhCloudOps

A PowerShell module providing utilities for GitHub Actions and cloud infrastructure deployments.

Functions

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.

Convert Bicep Parameter File

$tokenMap = @{
    name     = 'test'
    count    = 1
    enabled  = $true
    identity = $null
}

Convert-Token -InputFile 'params.bicepparam' -OutputFile 'expanded.bicepparam' -TokenMap $tokenMap

Tokenized Bicep Parameter File

using 'test.bicep'

param name = '{{ name }}'

param count = '{{ count }}'

param enabled = '{{ enabled }}'

param identity = '{{ identity }}'

Expanded Bicep Parameter File

using 'test.bicep'

param name = 'test'

param count = 1

param enabled = true

param identity = null

Convert Terraform Tfvars File

$tokenMap = @{
    name     = 'test'
    count    = 1
    enabled  = $true
    identity = $null
}

Convert-Token -InputFile 'params.tfvars' -OutputFile 'expanded.tfvars' -TokenMap $tokenMap

Tokenized Terraform Tfvars File

name = "{{ name }}"

count = "{{ count }}"

enabled = "{{ enabled }}"

identity = "{{ identity }}"

Expanded Terraform Tfvars File

name = "test"

count = 1

enabled = true

identity = null

Convert Json Parameter File

$tokenMap = @{
    name     = 'test'
    count    = 1
    enabled  = $true
    identity = $null
}

Convert-Token -InputFile 'params.json' -OutputFile 'expanded.json' -TokenMap $tokenMap

Tokenized Json Parameter File

{
    "name": "{{ name }}",
    "count": "{{ count }}",
    "enabled": "{{ enabled }}",
    "identity": "{{ identity }}"
}

Expanded Json Parameter File

{
    "name": "test",
    "count": 1,
    "enabled": true,
    "identity": null
}

Convert Psd1 File

$tokenMap = @{
    name     = 'test'
    count    = 1
    enabled  = $true
    identity = $null
}

Convert-Token -InputFile 'params.psd1' -OutputFile 'expanded.psd1' -TokenMap $tokenMap

Tokenized Psd1 File

@{
    name     = '{{ name }}'
    count    = '{{ count }}'
    enabled  = '{{ enabled }}'
    identity = '{{ identity }}'
}

Expanded Psd1 File

@{
    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' -IsOutput

Secret variables can be set as follows:

Set-GhVariable -Name 'DEPLOY_SECRET' -Value 'supersecret' -IsSecret
Set-GhVariable -Name 'DEPLOY_SECRET' -Value 'supersecret' -IsSecret -IsOutput

Note: Secret variables are not available to subsequent jobs in a workflow.

Generates a random secure string.

New-RandomSecret -Length 32

Returns 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

Testing

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 test

Building Locally

Use the VS Code "Build Locally" task or:

Invoke-Build -File ./build.ps1 -Task local_build

Requirements

  • PowerShell 7
  • GitHub Actions environment (for Set-GhVariable)

Installation

Install-Module -Name GhCloudOps

About

A PowerShell module providing utilities for GitHub Actions and cloud infrastructure deployments.

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages