Encodes a multiline string into one line for Github Action output.

encode_string(string, join = FALSE)

Arguments

string

A character vector.

join

Join vector into single string using encoded newline.

Value

A character vector (of length 1 if join).

Details

This will only encode '%', '\n', '\r' as these will be automatically decoded by Github when using the output via ${{ steps.<step_id>.outputs.<name> }}. You can use utils::URLencode() instead of this function to also escape everything else problematic like (double) quotes etc. but you will have to manually use utils::URLdecode() to revert this.

Examples

chrs <- c("100% This is some output with \n", "a new line")
encode_string(chrs)
#> Error in encode_string(chrs): could not find function "encode_string"

# encode some md (e.g. to post as comment)
md <- c("# Important PR Comment", " ", "This commit is great!")
encode_string(md, TRUE)
#> Error in encode_string(md, TRUE): could not find function "encode_string"