Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
eriqua committed Sep 18, 2023
2 parents 64aa6d8 + 6812445 commit fbc8712
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 78 deletions.
48 changes: 8 additions & 40 deletions .github/actions/templates/setEnvironment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@
## 'Set environment' Composite Action ##
#########################################################
##
## This composite action contains the logic to read a YAML file containing a list (dictionary) of key-value pairs and convert each key as an environment variable.
## Example YAML File content:
## listName:
## key1: 'value1'
## key2: 'value2'
## This composite action contains the logic to install any required asset on the runner.
##
#########################################################
##
##-------------------------------------------##
Expand All @@ -16,29 +13,26 @@
## |==================================================================================================================================================================|
## | Parameter | Required | Default | Description | Example |
## |--------------------|----------|---------|------------------------------------------------------------------------------------------|-----------------------------|
## | variablesPath | true | '' | The path to the YAML file that contains the key value pairs for environment variables | './settings.yml' |
## | removeDeployment | true | '' | Set "true" to setup runner with PowerShell modules needed for custom resource removal | 'truel' |
## |==================================================================================================================================================================|
##
##---------------------------------------------##

name: 'Set environment'
description: 'Set environment'
name: "Set environment"
description: "Set environment"

inputs:
variablesPath:
description: 'The path to the YAML file that contains the key value pairs for environment variables'
required: true
removeDeployment:
description: 'Set "true" to setup runner with PowerShell modules needed for custom resource removal'
default: 'true'
default: "true"
required: false

runs:
using: 'composite'
using: "composite"
steps:
# [Setup] task(s)
# ---------------
- name: 'Setup agent'
- name: "Setup agent"
shell: pwsh
run: |
# Grouping task logs
Expand Down Expand Up @@ -80,29 +74,3 @@ runs:
Set-EnvironmentOnAgent -PSModules $modules
Write-Output '::endgroup::'
# [Set environment] task(s)
# ---------------
- name: 'Set environment variables'
id: set-env-variables
shell: pwsh
run: |
# Grouping task logs
Write-Output '::group::Set environment variables'
# Load used functions
. (Join-Path $env:GITHUB_WORKSPACE 'utilities' 'pipelines' 'sharedScripts' 'Add-YamlListToFile.ps1')
$functionInput = @{
InputFilePath = '${{ inputs.variablesPath }}'
ListName = 'variables'
OutputFilePath = $Env:GITHUB_ENV
}
Write-Verbose "Invoke task with" -Verbose
Write-Verbose ($functionInput | ConvertTo-Json | Out-String) -Verbose
# Convert YAML Variable File to Environment Variables
Add-YamlListToFile @functionInput
Write-Output '::endgroup::'
36 changes: 18 additions & 18 deletions .github/actions/templates/validateModuleDeployment/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,32 @@
##
#########################################################

name: 'Deploy module'
description: 'Deploy module'
name: "Deploy module"
description: "Deploy module"

inputs:
templateFilePath:
description: 'The path to the template file to use for deployment'
description: "The path to the template file to use for deployment"
required: true
location:
description: 'The location to use for deployment'
description: "The location to use for deployment"
required: true
subscriptionId:
description: 'The subscription ID to deploy to'
description: "The subscription ID to deploy to"
required: false
managementGroupId:
description: 'The management group ID to deploy to'
description: "The management group ID to deploy to"
required: false
customTokens:
description: 'Additional parameter file token pairs in json format. e.g. {"tokenName":"tokenValue"}'
required: false
removeDeployment:
description: 'Set "true" to set module up for removal'
default: 'true'
default: "true"
required: false

runs:
using: 'composite'
using: "composite"
steps:
- name: Azure Login
uses: Azure/login@v1
Expand All @@ -59,10 +59,10 @@ runs:

# [Token replacement] task(s)
# ---------------------------
- name: 'Replace tokens in template file'
- name: "Replace tokens in template file"
uses: azure/powershell@v1
with:
azPSVersion: 'latest'
azPSVersion: "latest"
inlineScript: |
# Grouping task logs
Write-Output '::group::Replace tokens in template file'
Expand All @@ -77,8 +77,8 @@ runs:
$ConvertTokensInputs = @{
FilePathList = $targetFileList
Tokens = @{}
TokenPrefix = '${{ env.tokenPrefix }}'
TokenSuffix = '${{ env.tokenSuffix }}'
TokenPrefix = '[['
TokenSuffix = ']]'
}
# Add enforced tokens
Expand Down Expand Up @@ -118,10 +118,10 @@ runs:
# [Deployment validation] task(s)
# -------------------------------
- name: 'Validate template file'
- name: "Validate template file"
uses: azure/powershell@v1
with:
azPSVersion: 'latest'
azPSVersion: "latest"
inlineScript: |
# Grouping task logs
Write-Output '::group::Validate template file'
Expand Down Expand Up @@ -174,11 +174,11 @@ runs:
# [Deployment execution] task(s)
# ------------------------------
- name: 'Deploy template file'
- name: "Deploy template file"
id: deploy_step
uses: azure/powershell@v1
with:
azPSVersion: 'latest'
azPSVersion: "latest"
inlineScript: |
# Grouping task logs
Write-Output '::group::Deploy template file'
Expand Down Expand Up @@ -251,11 +251,11 @@ runs:
# [Deployment removal] task(s)
# ----------------------------
- name: 'Remove deployed resources'
- name: "Remove deployed resources"
if: ${{ (success() || failure()) && inputs.removeDeployment == 'true' && steps.deploy_step.outputs.deploymentNames != '' }}
uses: azure/powershell@v1
with:
azPSVersion: 'latest'
azPSVersion: "latest"
inlineScript: |
# Grouping task logs
Write-Output '::group::Remove deployed resources'
Expand Down
22 changes: 2 additions & 20 deletions .github/workflows/template.module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ on:
required: true

env:
variablesPath: 'settings.yml'
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
ARM_SUBSCRIPTION_ID: '${{ secrets.ARM_SUBSCRIPTION_ID }}'
ARM_MGMTGROUP_ID: '${{ secrets.ARM_MGMTGROUP_ID }}'
Expand All @@ -38,9 +37,7 @@ jobs:
# with:
# fetch-depth: 0
# - name: Set environment
# uses: ./.github/actions/templates/setEnvironment
# with:
# variablesPath: ${{ env.variablesPath }}
# uses: ./.github/actions/templates/setEnvironment}
# - name: 'Run tests'
# uses: ./.github/actions/templates/validateModulePester
# with:
Expand All @@ -63,8 +60,6 @@ jobs:
# uses: actions/checkout@v3
# - name: Set environment
# uses: ./.github/actions/templates/setEnvironment
# with:
# variablesPath: ${{ env.variablesPath }}
# - name: Set PSRule validation
# uses: ./.github/actions/templates/validateModulePSRule
# with:
Expand Down Expand Up @@ -97,13 +92,12 @@ jobs:
- name: Set environment
uses: ./.github/actions/templates/setEnvironment
with:
variablesPath: ${{ env.variablesPath }}
removeDeployment: '${{ fromJson(inputs.workflowInput).removeDeployment }}'
- name: 'Using test file [${{ matrix.moduleTestFilePaths }}]'
uses: ./.github/actions/templates/validateModuleDeployment
with:
templateFilePath: '${{ inputs.modulePath }}/${{ matrix.moduleTestFilePaths }}'
location: '${{ env.location }}'
location: 'WestEurope'
subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}'
managementGroupId: '${{ secrets.ARM_MGMTGROUP_ID }}'
removeDeployment: '${{ fromJson(inputs.workflowInput).removeDeployment }}'
Expand All @@ -124,20 +118,8 @@ jobs:
# fetch-depth: 0
# - name: Set environment
# uses: ./.github/actions/templates/setEnvironment
# with:
# variablesPath: ${{ env.variablesPath }}
# - name: 'Publishing'
# uses: ./.github/actions/templates/publishModule
# with:
# templateFilePath: '${{ inputs.modulePath }}/main.bicep'
# subscriptionId: '${{ secrets.ARM_SUBSCRIPTION_ID }}'
# templateSpecsRGName: '${{ env.templateSpecsRGName }}'
# templateSpecsRGLocation: '${{ env.templateSpecsRGLocation }}'
# templateSpecsDescription: '${{ env.templateSpecsDescription }}'
# templateSpecsDoPublish: '${{ env.templateSpecsDoPublish }}'
# bicepRegistryName: '${{ env.bicepRegistryName }}'
# bicepRegistryRGName: '${{ env.bicepRegistryRGName }}'
# bicepRegistryRgLocation: '${{ env.bicepRegistryRgLocation }}'
# bicepRegistryDoPublish: '${{ env.bicepRegistryDoPublish }}'
# publishLatest: '${{ env.publishLatest }}'
# useApiSpecsAlignedName: '${{ env.useApiSpecsAlignedName }}'

0 comments on commit fbc8712

Please sign in to comment.