What do `contains`, `startsWith`, `endsWith`, `format` and `join` do?
BeginnerConceptContexts, Expressions, Env & Outputs
Answer
if: contains(github.event.pull_request.labels.*.name, 'deploy-preview')
if: startsWith(github.ref, 'refs/tags/v')
if: endsWith(github.repository, '-infra')
run: echo "${{ format('{0}/{1}:{2}', vars.REGISTRY, 'api', github.sha) }}"
run: echo "Targets ${{ join(matrix.targets, ', ') }}"
contains works on strings (substring, case-insensitive) and arrays (element match). format uses {0} placeholders and {{ to escape braces.
More on Contexts, Expressions, Env & Outputs
List the available contexts and what each holds.BeginnerWhich contexts can you use in which keys? Give two examples that trip people up.AdvancedWhat are the expression operators and how do comparisons coerce types?IntermediateHow do you write a ternary in GitHub Actions expressions?IntermediateWhat are object filters (`.*`) and how are they useful?IntermediateWhat do `toJSON` and `fromJSON` do, and give a real use of each?Intermediate