Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitHub Actions expression functions: string manipulation?

In a GitHub Actions workflow definition file, there's a set of built-in functions that you can use in expressions.

For example: ${{ toJson(github) }}

Are there any string manipulation functions that can be used in an expression, such as toLowerCase?

The documentation page doesn't mention any. However, I'm wondering if Github uses some sort of standard templating / expression eval library under the hood which has provides a larger set of functions out of the box.

like image 240
Max Avatar asked Jun 28 '20 20:06

Max


1 Answers

Impossible. GitHub expressions doesn't allow string modification, only concatenation.

You could do almost the same with a custom step in a build job, but this means that you won't be able to use that variable everywhere (for example "processed" environment name is out of the question).

env:
  UPPERCASE_VAR: "HELLO"
steps:
  - id: toLowerCase
    run: INPUT=${{ env.UPPERCASE_VAR }} echo "::set-output name=lowerCaseValue::${INPUT,,}"

  - run: echo ${{steps.toLowerCase.outputs.lowerCaseValue}}
like image 126
Vilius Sutkus '89 Avatar answered Sep 21 '22 20:09

Vilius Sutkus '89