Merges data into an existing structured file.
Input Schema
| Property | Type | Description | Required |
|---|---|---|---|
| path | string | - | |
| content | any | - | |
| mergeArrays | boolean | - | |
| preserveYamlComments | boolean | - | |
| useDocumentIncludingField | object | - |
Output Schema
| Property | Type | Description | Required |
|---|---|---|---|
| path | string | - |
Usage Examples
Add scripts and keywords to package.json while appending arrays
Adds scripts and keywords to an existing package.json. Use this when you want to customize a generated project without overwriting existing keyword entries pulled in via fetch:template.
steps:
- id: fetch-base
action: fetch:template
input:
url: ./skeleton
targetPath: .
values:
componentId: ${{ parameters.componentId }}
language: ${{ parameters.language }}
- id: merge-package-json
action: roadiehq:utils:merge
input:
path: package.json
content:
name: "@acme/${{ parameters.componentId }}"
scripts:
lint: "eslint ."
test: "jest --coverage"
start: "node dist/index.js"
keywords:
- backstage
- service
- ${{ parameters.language }}
mergeArrays: truePreserve comments while updating app-config.yaml
Updates Backstage configuration while keeping YAML comments intact. Use this to safely adjust common settings without losing documented notes in app-config.yaml fetched by fetch:template.
steps:
- id: fetch-skeleton
action: fetch:template
input:
url: ./skeleton
targetPath: .
values:
componentId: ${{ parameters.componentId }}
- id: merge-app-config
action: roadiehq:utils:merge
input:
path: app-config.yaml
content:
app:
title: "Acme Developer Portal"
backend:
baseUrl: "https://backstage.acme.internal"
techdocs:
generator:
runIn: "local"
catalog:
locations:
- type: file
target: "./catalog-info.yaml"
preserveYamlComments: trueTarget a specific entity in a multi-document catalog-info.yaml
Merges metadata and spec fields into the correct entity within a multi-document catalog-info.yaml. Use this when your template includes multiple entities and you only want to update the Component matching the given name after fetch:template.
steps:
- id: fetch-entities
action: fetch:template
input:
url: ./skeleton
targetPath: .
values:
componentId: ${{ parameters.componentId }}
- id: merge-component-entity
action: roadiehq:utils:merge
input:
path: catalog-info.yaml
useDocumentIncludingField:
kind: Component
metadata:
name: ${{ parameters.componentId }}
content:
metadata:
annotations:
backstage.io/techdocs-ref: dir:.
tags:
- node
- web
spec:
lifecycle: production
owner: "group:platform"
mergeArrays: trueReplace include and exclude arrays in tsconfig.json
Updates TypeScript compiler options and replaces include and exclude arrays. Use this to enforce your preferred tsconfig after pulling a base config with fetch:template.
steps:
- id: fetch-ts
action: fetch:template
input:
url: ./skeleton
targetPath: .
values:
componentId: ${{ parameters.componentId }}
- id: merge-tsconfig
action: roadiehq:utils:merge
input:
path: tsconfig.json
content:
compilerOptions:
target: ES2021
module: CommonJS
strict: true
outDir: dist
include:
- src/**/*.ts
exclude:
- node_modules
- dist
mergeArrays: falseAppend a CI step to a GitHub Actions workflow
Adds a new step to an existing job in .github/workflows/ci.yml without overwriting other steps. Use this to extend CI after the base workflow is created by fetch:template.
steps:
- id: fetch-repo
action: fetch:template
input:
url: ./skeleton
targetPath: .
values:
componentId: ${{ parameters.componentId }}
- id: merge-ci-workflow
action: roadiehq:utils:merge
input:
path: .github/workflows/ci.yml
content:
jobs:
build:
steps:
- name: Run database migrations
run: npm run migrate
env:
SERVICE_NAME: ${{ parameters.componentId }}
mergeArrays: true