https://github.com/andreasnel/string-vars-action
An action to replace variables in a given string.
https://github.com/andreasnel/string-vars-action
Last synced: 5 months ago
JSON representation
An action to replace variables in a given string.
- Host: GitHub
- URL: https://github.com/andreasnel/string-vars-action
- Owner: AndreasNel
- License: mit
- Created: 2020-07-11T12:52:34.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-11-18T18:13:06.000Z (about 1 year ago)
- Last Synced: 2024-11-22T10:45:57.800Z (about 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 1.19 MB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# string-vars-action


An action to replace variables in a given string.
It expects a string containing any number of placeholders, and then attempts to populate them from the currently available environment variables.
## Inputs
### instring
The input string containing the lowercase variable names, surrounded by curly braces. **required**
### prefix
The prefix to use when inspecting the environment. Only environment variables starting with the prefix will be used when replacing the placeholders. **optional**
## Outputs
### outstring
The string after substituting the placeholders.
## Example Usage
```yaml
name: String Replace Test
on:
push:
branches: master
jobs:
example:
runs-on: ubuntu-latest
steps:
- name: 'With prefix'
env:
STRVAR_ONE: '1'
STRVAR_TWO: '2'
ONE: '3'
uses: AndreasNel/string-vars-action@master
with:
prefix: 'STRVAR_'
instring: '{ONE} {ONE} {TWO}'
- name: 'Without prefix'
env:
ONE: '1'
TWO: '2'
uses: AndreasNel/string-vars-action@master
with:
instring: '{ONE} {ONE} {TWO}'
```
In both cases, the string `1 1 2` will be the output.