Skip to content

Commit

Permalink
gh-actions/str/sub: Add action (#876)
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Northey <[email protected]>
  • Loading branch information
phlax authored Oct 22, 2023
1 parent fc10b7b commit f0a893b
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions gh-actions/str/sub/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

inputs:
string:
required: true
start:
type: number
default: 0
length:
type: number
required: true
min:
type: number

outputs:
string:
value: ${{ steps.substr.outputs.string }}

runs:
using: composite
steps:
- run: |
if [[ -z "$MIN" || "${#STRING}" -lt "${MIN}" ]]; then
echo "string=${STRING}" >> $GITHUB_OUTPUT
else
echo "string=${STRING:$START:$LENGTH}" >> $GITHUB_OUTPUT
fi
id: substr
shell: bash
env:
STRING: ${{ inputs.string }}
START: ${{ inputs.start }}
LENGTH: ${{ inputs.length }}
MIN: ${{ inputs.min }}

0 comments on commit f0a893b

Please sign in to comment.