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: >
  ./mvnw -f my/pom.xml
  clean verify

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 a Literal Block Scalar which preserves new lines and trailing spaces
  • > called a Folded Block Scalar which converts new lines into spaces
  • plain old strings, either unquoted, single-quoted or double-quoted

I found the site 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");
   echo "File: ${i} \n";
   cat $i;
   printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -;