encode_string: Encode String for GitHub Actions

View source: R/util.R

encode_stringR Documentation

Encode String for GitHub Actions

Description

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

Usage

encode_string(string, join = FALSE)

Arguments

string

A character vector.

join

Join vector into single string using encoded newline.

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.

Value

A character vector (of length 1 if join).

Examples

chrs <- c("100% This is some output with \n", "a new line")
encode_string(chrs)

# encode some md (e.g. to post as comment)
md <- c("# Important PR Comment", " ", "This commit is great!")
encode_string(md, TRUE)

assignUser/octolog documentation built on June 4, 2023, 3:28 p.m.