[Feature Request] YML Function: Replace/Substitute

Hello!

I’d really like to be able to use a function like

replace(string, to_replace, out)

in Action workflow yml files. This function and

format

should allow any string to be produced. Regex functionality is overkill IMO but I’m sure some will complain without it :slight_smile:

My main usage right now would be to strip

refs/heads

from the

${{ github.ref }}

context string.

Scott

(Also how can I not write gh-flavored markdown in this post? Who in their right mind made that decision?)

22 Likes

Hi @sburns,

Thanks for this feedback! We’re always working to improve GitHub and the GitHub Community Forum, and we consider every suggestion we receive. I’ve logged your feature request in our internal feature request list. Though I can’t guarantee anything or share a timeline for this, I can tell you that it’s been shared with the appropriate teams for consideration.

Cheers!

2 Likes

Hi, is this implemented yet?

I ran into another case where a function like this would have been useful.

I’ve got a work flow that uses a matrix strategy to pick a Docker container to run in via container: ${{ matrix.image }}. So far so good.

I then wanted to add a step to collect logs into an artifact if the build or tests failed. As each parallel job would be writing log files with the same name, I need to use unique artifact names:

  - name: Collect logs on failure
    if: failure()
    uses: actions/upload-artifact@v2
    with:
      name: ${{ matrix.image }} logs
      path: _build/meson-logs

Unfortunately the docker image names have colons in them, which the upload-artifact action rejects as an artifact name. So being able to do something like ${{ replace(matrix.image, ':', '-') }} would have been quite useful here.

I realise I have other options here, such as writing a step that generates an appropriate output parameter using sed. I just thought I’d mention this as another use case for this feature request.