Skip to content

Commit

Permalink
Extend replace-string to handle multiple replaces
Browse files Browse the repository at this point in the history
  • Loading branch information
mikogs committed Oct 30, 2023
1 parent 827c356 commit 70d26fe
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 29,959 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/test-replace-string.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,35 @@ jobs:
if [[ "${output_from_file}" != 'Cranberry and red apple' ]]; then
echo "!!! Action failed to create an output file with replaced string"
fi
- name: Create a dummy file with multiple variables
id: from-file-with-multiple
run: |
cat >tmp-read-from-file-multiple.txt <<EOF
Line without anything to replace
The following should contain an apple: __APPLE__ is red
And the following shall be '$AZERO': __CURRENCY__
Thanks!
EOF
cat >tmp-write-to-file-multiple-expected.txt <<EOF
Line without anything to replace
The following should contain an apple: apple is red
And the following shall be '$AZERO': $AZERO
Thanks!
EOF
- name: Replace multiple strings
uses: ./replace-string
with:
read-from-file: 'tmp-read-from-file-multiple.txt'
replace-regex: |-
__APPLE__
__CURRENCY__
replace-with: |-
apple
$AZERO
write-to-file: 'tmp-write-to-file-multiple.txt'

- name: Check multistring replacement
run: |
diff tmp-write-to-file-multiple.txt tmp-write-to-file-multiple-expected.txt
Loading

0 comments on commit 70d26fe

Please sign in to comment.