Skip to content

Substring function? #26625

Answered by jclem
vaadin-miki asked this question in Actions
May 12, 2020 · 5 comments · 17 replies
Discussion options

You must be logged in to vote

Unfortunately, there’s currently no built-in substring function. As a workaround, you can use another action and set the substring as an output variable:

- id: get-id
  run: |
    id=$(echo ${{github.event.client_payload.value}} | cut -d- -f2)
    echo "::set-output name=id::$id"
- run: echo "${{steps.get-id.outputs.id}}"

In this example, I’ve added a step with the ID get-id. That step splits the value that I want to split using cut and then sets it as an output parameter, which can be read and used by subsequent actions.

If you’re not familiar with cut, it’s a shell command that splits a string based on a delimiter (-d) and outputs a specific field (-f). You could use any shell we suppo…

Replies: 5 comments 17 replies

Comment options

You must be logged in to vote
9 replies
@laeubi
Comment options

@TWiStErRob
Comment options

@hfhbd
Comment options

@TWiStErRob
Comment options

@hfhbd
Comment options

Answer selected
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@tgillitzer
Comment options

@bayocr
Comment options

@salvianreynaldi
Comment options

Comment options

You must be logged in to vote
5 replies
@boorad
Comment options

@dlech
Comment options

@dhirschfeld
Comment options

@TWiStErRob
Comment options

@dekimsey
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment