diff --git a/README.md b/README.md index 5260181..1e941c0 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/action.yml b/action.yml index ae6c5c1..22ae4f9 100644 --- a/action.yml +++ b/action.yml @@ -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