Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github Action: Split Long Command into Multiple Lines

I have a Github action command that is really long:

name: build

on: [push]

jobs:
    build:
        runs-on: ubuntu-18.04
        steps:
            - uses: actions/checkout@v1
            - name: Install Prerequisites
              run: |
                sudo apt-get update
                sudo apt-get install -y --no-install-recommends "a very very long list of prerequisites"

May I know whether it is possible to split the long command into multiple lines for better readability? I have tried the separator '' but it does not work.

like image 994
Bojian Zheng Avatar asked Jan 28 '20 17:01

Bojian Zheng


2 Answers

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.

like image 170
Mike De Marco Avatar answered Oct 07 '22 13:10

Mike De Marco


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
like image 105
lorenzo-bettini Avatar answered Oct 07 '22 12:10

lorenzo-bettini