Github Action: Split Long Command into Multiple Lines
I have a multi line command using backslash to separate the lines as follows:
- name: Configure functions
run: |
firebase functions:config:set \
some.key1="${{ secrets.SOME_KEY_1 }}" \
some.key2="${{ secrets.SOME_KEY_2 }}" \
...
Note the preceding '|' character.
You can use the YAML folded style with >
which is supported by GitHub Actions.
For example,
run: >
xvfb-run
./mvnw -f my/pom.xml
clean verify
-DskipTests
newlines will be replaced with spaces so the above is equivalent to
run: xvfb-run ./mvnw -f my/pom.xml clean verify -DskipTests
Going to share this in since it has not been mentioned.
You can use:
|
called aLiteral Block Scalar
which preserves new lines and trailing spaces>
called aFolded Block Scalar
which converts new lines into spaces- plain old strings, either unquoted, single-quoted or double-quoted
I found the site yaml-multiline.info useful for understanding how yaml strings are interpreted.
For my use case, I ended up doing the following:
run: >-
for i in $(find . -type f -name "*.log");
do
echo "File: ${i} \n";
cat $i;
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -;
done