Merges multiple files and writes the combined output to a specified destination.
Input Schema
| Property | Type | Description | Required |
|---|---|---|---|
| options | any | - | |
| outputPath | string | The path to write the merged HCL content to | |
| aSourcePath | string | The path to the HCL file to be merged | |
| bSourcePath | string | The path to the HCL file to be merged |
Output Schema
Usage Examples
Merge environment-specific Terraform HCL files before publishing to GitHub
Runs hcl:merge:files:write in an environment folder after fetching template files. Use this when your template generates multiple HCL fragments for a Terraform environment that need to be merged before publishing. This example shows the action in a typical flow with fetch:template, publish:github, and [catalog:register](/backstage/scaffolder-actions/catalo g-register).
steps:
- id: fetchBase
action: fetch:template
input:
url: ./skeleton
targetPath: .
values:
component_id: ${{ parameters.name }}
owner: ${{ parameters.owner }}
environment: ${{ parameters.environment }}
- id: mergeHclEnv
action: hcl:merge:files:write
workingDirectory: terraform/environments/${{ parameters.environment }}
- id: publishRepo
action: publish:github
input:
repoUrl: github.com?owner=${{ parameters.owner }}&repo=${{ parameters.name }}
defaultBranch: main
repoVisibility: private
protectDefaultBranch: true
- id: register
action: catalog:register
input:
repoContentsUrl: ${{ steps.publishRepo.output.repoContentsUrl }}
catalogInfoPath: /catalog-info.yamlConditionally merge HCL files for a module in a monorepo
Only runs hcl:merge:files:write when a parameter is enabled, targeting a specific module folder. Use this to optionally merge HCL inputs for certain modules (for example networking) before publishing with publish:github.
steps:
- id: fetchTemplate
action: fetch:template
input:
url: ./skeleton
targetPath: .
values:
component_id: ${{ parameters.name }}
owner: ${{ parameters.owner }}
includeNetworking: ${{ parameters.includeNetworking }}
- id: mergeHclModule
action: hcl:merge:files:write
if: ${{ parameters.includeNetworking }}
workingDirectory: infrastructure/modules/network
- id: publish
action: publish:github
input:
repoUrl: github.com?owner=${{ parameters.owner }}&repo=infra-${{ parameters.name }}
defaultBranch: main
repoVisibility: internal
gitCommitMessage: "scaffold: initial infrastructure with optional networking module"