Which expression uses the format function to produce the string 'build-42' when github.run_number is 42?
Select an answer to reveal the explanation.
Short Explanation and Infographic
format() uses zero-based positional placeholders like {0}, {1}. Python f-strings, printf %d, and empty {} braces are not the Actions format syntax.
Full explanation below image
Full Explanation
The format(string, replace0, replace1, ...) function substitutes {0}, {1}, and similar placeholders with the provided arguments. format('build-{0}', github.run_number) therefore yields build-42 when run_number is 42. Empty braces {} without an index are not valid in this dialect. printf-style %d tokens are not supported. Python f-string syntax is not valid inside GitHub Actions expressions. format is useful for composing artifact names, cache keys, and notification messages. You can pass multiple replacements: format('{0}-{1}', env.APP, github.sha). For simple concatenation some authors use other patterns, but format keeps multi-part strings readable and explicit.