Skip to content

Find-and-replace strings

Actions
Finds and replaces text on a string
5
Latest
Star (16)

Find and replace strings

This action executes find-and-replace on a given string (hint: use ${{ github.ref }} to get your branch name and apply this on it for use in another action).

Inputs

source

Required The source string to apply this action to

find

Required The text you want to search for within the branch name (eg. ref/heads/)

replace

Required The text you want to replace (eg. head-, ``, root_)

replaceAll

Optional Should replace all occurrences? (only 'true' string will be interpreted positive)

Outputs

value

The new value containing the found-and-replaced string.

Example usage

uses: mad9000/actions-find-and-replace-string@5
with:
    source: ${{ github.ref }} # this translates to ref/heads/main on the main branch, but can be any arbitrary string 
    find: 'ref/heads/'        # we want to remove ref/heads/ from source 
    replace: ''               # and replace it with a blank string (ie. removing it)

This will output main.

Check out .github/workflows/main.yml for more examples

Find-and-replace strings is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

Finds and replaces text on a string
5
Latest

Find-and-replace strings is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.