Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# replace-action

This lightweight action replaces substrings in files. It is useful for CI process when you needto update your configs depending on the previous steps results.
This lightweight action replaces substrings in files. It is useful for CI process when you need to update your configs depending on the previous steps results.

# Usage

Expand All @@ -11,8 +11,9 @@ See [action.yml](action.yml)
uses: datamonsters/replace-action
with:
files: 'path1/file1,path2/file2'
replacements: 'foo=bar,$FOO=Bar_Value'
replacements: 'foo=bar,@FOO=Bar_Value'
```
As the replacement is using regular expression, you should avoid 'special' characters which might be misinterpreted in the RegEx context.

# Example

Expand Down Expand Up @@ -73,4 +74,4 @@ jobs:

# License

The scripts and documentation in this project are released under the [MIT License](LICENSE)
The scripts and documentation in this project are released under the [MIT License](LICENSE)
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ try {
var kv = vars[i].split('=')
var key = kv[0]
var value = kv[1]
result = result.replace(key, value)
var regx = new RegExp(key, 'g')
result = result.replace(regx, value)
}
console.log('file2: '+filename)
fs.writeFile(filename, result, 'utf8', function (err) {
Expand Down