https://github.com/nambers/replacestringinfile
https://github.com/nambers/replacestringinfile
Last synced: 1 day ago
JSON representation
- Host: GitHub
- URL: https://github.com/nambers/replacestringinfile
- Owner: Nambers
- License: mit
- Created: 2022-10-18T13:26:10.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-03T20:41:47.000Z (over 3 years ago)
- Last Synced: 2025-03-05T13:38:45.813Z (over 1 year ago)
- Language: JavaScript
- Size: 659 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ReplaceStringInFile action
[](https://github.com/Nambers/ReplaceStringInFile/actions/workflows/test.yaml)
This action replace string in file.
It works on both Linux and Windows.
This action uses `sed` in Linux and `powershell shell code` in Windows to replace.
## Inputs
### `path`
The path of the file.
**Required**.
### `oldString`
General `oldString` regex used both in Linux and Windows.
**Required**.
### `oldStringWin`
`oldString` regex used in Windows OS. If this exist, action will use this one instead of general `oldString`.
### `oldStringLinux`
`oldString` regex used in Linux OS. If this exist, action will use this one instead of general `oldString`.
### `newString`
General `newString` used both in Linux and Windows.
**Required** Default ''.
### `newStringWin`
`newString` used in Windows OS. If this exist, action will use this one instead of general `newString`.
Default: 'nullForStringInAction'.
### `newStringLinux`
`newString` used in Linux OS. If this exist, action will use this one instead of general `newString`.
Default: 'nullForStringInAction'.
### `regexOptions`
Regex options.
Default: 'g'.
### `escapeBackslash`
Escape backslash ( \ -> \\\ in win and \ -> / ).
Default: false
### `showFileContent`
If it equal to ture, action will print out file content after replacement finished.
Action uses `cat` in Linux and `type` in Windows to print.
Default: false.
## Example usage
[test.yaml](.github/workflows/test.yaml)
```yaml
- name: replace
uses: Nambers/ReplaceStringInFile@v1
with:
path: ${{ github.workspace }}/a.test
oldString: abc123))
oldStringWin: abc123\)\)
newString: --_
showFileContent: true
```