Skip to content

Custom Replacement file

Andre_601 edited this page Feb 12, 2022 · 1 revision

About

Readme Replacer allows you to define custom placeholders to replace through a JSON file.

You can set your own JSON file by using the CUSTOM_REPLACER_FILE option in the Workflow's with settings.

Example:

name: Replace placeholders

on:
  schedule:
    - cron: '*/30 * * * *' # Activate every 30 minutes
  workflow_dispatch: # Allow manual trigger

jobs:
  replace:
    runs-on: ubuntu-latest
    name: Replace Placeholders in File.
    
    steps:
      - uses: actions/checkout@v2
      - uses: Readme-Workflows/[email protected]
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          CUSTOM_REPLACER_FILE: './my-custom-replacer.json'

Format

The file follows a specific format that you need to keep in mind, to avoid any errors.
In detail does the file have JSON objects/sections, which can have the following keys defined.

comment

This is an optional setting that allows you to set a comment. This can be useful, if you have new contributed that wonder what this particular placeholder is good for.

It has no influence on the result.

search

This is the placeholder that the action should look for in the template Markdown file.

It can be any String you like, but it is recommended to stick with a specific placeholder pattern to avoid confusion and to stay consistent. Recommended placeholder patterns are {placeholder} or %placeholder%.

replace

The value that the placeholder should be replaced with.

This can be any String you like. If the eval option is set to true can you also set Javascript syntaxes that would then be evaluated.

eval

This boolean option sets, if the replace value should be evaluated before the replacement.

This can be useful if you want to set dynamically changing values, such as the current date and time (new Date().toLocaleString)

Clone this wiki locally