This action searches matching files for strings and replaces any matches with replacement values, then saves the modified file(s).
steps:
- uses: actions/checkout@v5
- uses: flcdrg/replace-multiple-action@v2
with:
files: './*.md'
find: '[{ "find": "Multiple", "replace": "Many" }]'
Search for Markdown files in the current directory. In each matching file, search for Markdown links. eg. that start the line, have whitespace or a left bracket preceding them, and have an end of line, whitespace or right bracket immediately after them.
steps:
- uses: flcdrg/replace-multiple-action@v2
with:
files: './*.md'
find: '[{ "find": "http://localhost", "replace": "https://localhost"}, { "find": "http://davidgardiner.net.au", "replace": "https://david.gardiner.net.au" }]'
prefix: '(^|\\s+|\\()'
suffix: '($|\\s+|\\))'
The replacements
output from the flcdrg/wayback-machine-query-action
action is the correct shape to be passed in to the find
input for this action.
steps:
- name: Wayback Machine Query
uses: flcdrg/wayback-machine-query-action@v2
id: wayback
with:
source-path: ./lychee/links.json
timestamp-regex: '_posts\/(\d+)\/(?<year>\d+)-(?<month>\d+)-(?<day>\d+)-'
- name: Replacements
uses: flcdrg/replace-multiple-action@v2
with:
find: ${{ steps.wayback.outputs.replacements }}
prefix: '(^|\\s+|\\()'
suffix: '($|\\s+|\\))'
Various inputs are defined in action.yml
to let you configure this action:
Name | Description | Default |
---|---|---|
files |
A wildcard glob used to match files that should be searched | **/*.md |
find |
A JSON array of strings to find and values to replace. The JSON array should conform to this structure. { find: string; replace: string; }[] |
|
prefix |
(optional) Part of a regular expression that is prepended to the search string to add additional context on when to match the string. The matched value of this regular expression group also prepended to the replacement value. | |
suffix |
(optional) Part of a regular expression that is appended to the search string to add additional context on when to match the string. The matched value of this regular expression group is also appended to the replacement value. |
Replace multiple strings in files is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.