Replaces content of a file with given values.
Input Schema
| Property | Type | Description | Required |
|---|---|---|---|
| files | array | - |
Output Schema
Usage Examples
Replace template placeholders in README and config files
Use this to update placeholder text in generated files after fetching a template with fetch:template. It replaces values in multiple files before pushing the repo with publish:github.
steps:
- id: fetch-base
action: fetch:template
input:
url: ${{ parameters.templateUrl }}
- id: replace-placeholders
action: roadiehq:utils:fs:replace
input:
files:
- file: README.md
find: "Template Service"
replace: "${{ parameters.name }}"
- file: README.md
find: "ACME Team"
replace: "${{ parameters.owner }}"
- file: config/default.yaml
find: "service-id: template-service"
replace: "service-id: ${{ parameters.componentId }}"
- id: publish
action: publish:github
input:
repoUrl: "github.com?owner=${{ parameters.owner }}&repo=${{ parameters.componentId }}"Update package and deployment metadata after generation
Use this when you need to set the component ID, version, and image reference in JSON and YAML files. It runs after fetch:template and before repository publish with publish:github.
steps:
- id: fetch-template
action: fetch:template
input:
url: ${{ parameters.templateUrl }}
- id: replace-metadata
action: roadiehq:utils:fs:replace
input:
files:
- file: package.json
find: "\"name\": \"my-template\""
replace: "\"name\": \"${{ parameters.componentId }}\""
- file: package.json
find: "\"version\": \"0.0.0\""
replace: "\"version\": \"${{ parameters.version }}\""
- file: chart/values.yaml
find: "repository: myorg/my-image"
replace: "repository: ${{ parameters.imageRepository }}"
- file: chart/values.yaml
find: "tag: latest"
replace: "tag: ${{ parameters.version }}"
- id: publish
action: publish:github
input:
repoUrl: "github.com?owner=${{ parameters.owner }}&repo=${{ parameters.componentId }}"