10

what the meaning of the character '|' after 'run: ' in the yml file of github action? i need to understand that.thanks here is code seg:

  • name: npm install run: | npm install env: CI: true

    # 运行脚本
    - name: 运行脚本
      run: |
        COOKIE='${{ secrets.COOKIE }}' DINGTALK_WEBHOOK='${{ secrets.DINGTALK_WEBHOOK }}' DINGTALK_SECRET='${{ secrets.DINGTALK_SECRET }}' ALL_IN='${{ secrets.ALL_IN }}' WX_COMPANY_ID='${{ secrets.WX_COMPANY_ID }}' WX_APP_ID='${{ secrets.WX_APP_ID }}' WX_APP_SECRET='${{ secrets.WX_APP_SECRET }}' FEISHU_WEBHOOK='${{ secrets.FEISHU_WEBHOOK }}' FEISHU_SECRET='${{ secrets.FEISHU_SECRET }}' npm start
      env:
        CI: true
    
zadaji
  • 141
  • 6

1 Answers1

10

According to the documentation :

Values can span multiple lines using | or >. Spanning multiple lines using a “Literal Block Scalar” | will include the newlines and any trailing spaces. Using a “Folded Block Scalar” > will fold newlines to spaces; it’s used to make what would otherwise be a very long line easier to read and edit. In either case the indentation will be ignored

Tom
  • 4,972
  • 3
  • 10
  • 28
  • 8
    Just to make perfectly clear: `|` and `>` are yaml constructs and not specific to GitHub actions. – DavidS Jan 10 '23 at 23:35
  • Ahh, @DavidS, good point, thanks! For someone (like me) new to both GHA and YAML, this was not at all obvious at first sight. – Sz. Jan 22 '23 at 17:43