Search code examples
githubyamlgithub-actions

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.


Solution

  • 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, and make sure the subsequent lines after the first one are indented (tabulated).