GH-200 · Question #75
As a developer, which of the following snippets will enable you to run the commands npm ci and npm run build as part of a workflow?
The correct answer is A. - run: |. To run multiple shell commands in a single step, use the run: key with the block scalar indicator | (pipe), which preserves newlines and allows multi-line commands: ``yaml run: | npm ci npm run build ` The | character is YAML syntax for a literal block scalar, treating each…
Question
As a developer, which of the following snippets will enable you to run the commands npm ci and npm run build as part of a workflow?
Options
- A
- run: |
- B
- shell:
- C
- run: |
- D
- run:
- E
- shell: |
How the community answered
(29 responses)- A86% (25)
- B7% (2)
- C3% (1)
- E3% (1)
Explanation
To run multiple shell commands in a single step, use the run: key with the block scalar indicator | (pipe), which preserves newlines and allows multi-line commands:
- run: |
npm ci
npm run build
The | character is YAML syntax for a literal block scalar, treating each line as a separate command. Options using shell: (B, E) are not valid GitHub Actions step keys for running commands - shell: is a sub-key of run: to specify the shell type, not a standalone key. Option D (- run: without |) would only support a single inline command, not multiple lines.
Topics
Community Discussion
No community discussion yet for this question.