Skip to content

Commit

Permalink
Add usage example
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasNel committed Jul 12, 2020
1 parent 8462f25 commit a23c214
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
47 changes: 46 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,49 @@ 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.

TODO: Add example usage.
## 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.
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ inputs:
# Add this if Github starts allowing structured data for inputs.
# variables:
# description: 'Key value pairs of the variable name and the value that it should have.'
# required: true
# required: false
instring:
description: 'The string containing the variable names.'
required: true
Expand Down

0 comments on commit a23c214

Please sign in to comment.