Creates a file with the content on the given path
Input Schema
| Property | Type | Description | Required |
|---|---|---|---|
| path | string | - | |
| content | string | - | |
| preserveFormatting | boolean | - |
Output Schema
| Property | Type | Description | Required |
|---|---|---|---|
| path | string | - |
Usage Examples
Create a service-specific .env file
Writes a .env file with runtime configuration for a new service. Use after fetching a base skeleton with fetch:template.
steps:
- id: fetchBase
action: fetch:template
input:
url: ./skeleton
targetPath: ./
- id: writeEnvFile
action: roadiehq:utils:fs:write
input:
path: services/${{ parameters.serviceId }}/.env
preserveFormatting: true
content: |
NODE_ENV=production
SERVICE_NAME=${{ parameters.serviceId }}
PORT=${{ parameters.port }}
DATABASE_URL=${{ parameters.databaseUrl }}
LOG_LEVEL=infoGenerate a README.md with project metadata
Creates a README.md populated with template parameters like name, owner, and description. Run after fetch:template to ensure the repository structure exists.
steps:
- id: fetchBase
action: fetch:template
input:
url: ./skeleton
targetPath: ./
- id: writeReadme
action: roadiehq:utils:fs:write
input:
path: README.md
preserveFormatting: true
content: |
# ${{ parameters.name }}
Owner: ${{ parameters.owner }}
## Description
${{ parameters.description }}
## Getting Started
- Install dependencies: `pnpm install`
- Run locally: `pnpm dev --port ${{ parameters.port }}`Write a JSON application config
Generates a JSON config file with values derived from parameters. Useful for app settings that will be read at runtime after fetch:template.
steps:
- id: fetchBase
action: fetch:template
input:
url: ./skeleton
targetPath: ./
- id: writeJsonConfig
action: roadiehq:utils:fs:write
input:
path: config/app-config.json
preserveFormatting: true
content: |
{
"serviceId": "${{ parameters.serviceId }}",
"owner": "${{ parameters.owner }}",
"port": ${{ parameters.port }},
"features": {
"metrics": true,
"tracing": ${{ parameters.enableTracing }}
}
}Create a Kubernetes deployment manifest
Writes a Kubernetes Deployment manifest into a k8s directory. Use after fetch:template when generating deployment assets.
steps:
- id: fetchBase
action: fetch:template
input:
url: ./skeleton
targetPath: ./
- id: writeK8sDeployment
action: roadiehq:utils:fs:write
input:
path: deploy/k8s/deployment.yaml
preserveFormatting: true
content: |
apiVersion: apps/v1
kind: Deployment
metadata:
name: ${{ parameters.serviceId }}
labels:
app: ${{ parameters.serviceId }}
spec:
replicas: 2
selector:
matchLabels:
app: ${{ parameters.serviceId }}
template:
metadata:
labels:
app: ${{ parameters.serviceId }}
spec:
containers:
- name: ${{ parameters.serviceId }}
image: ${{ parameters.imageRepository }}:${{ parameters.imageTag }}
ports:
- containerPort: ${{ parameters.port }}
env:
- name: LOG_LEVEL
value: "info"Add a GitHub Actions CI workflow
Creates a basic CI workflow YAML for Node.js projects. Place it under .github/workflows after fetch:template.
steps:
- id: fetchBase
action: fetch:template
input:
url: ./skeleton
targetPath: ./
- id: writeCiWorkflow
action: roadiehq:utils:fs:write
input:
path: .github/workflows/ci.yaml
preserveFormatting: true
content: |
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ parameters.nodeVersion }}
cache: pnpm
- run: corepack enable
- run: pnpm install --frozen-lockfile
- run: pnpm test