Code Monkey home page Code Monkey logo

Comments (9)

MetRonnie avatar MetRonnie commented on August 22, 2024 17

@uditgaurav

My if condition is very larger in size and I want to write it in multiple lines. Is there any way to do that?

Much like you would use |, use >- (the "block styles with block chomping indicator"). Unlike |, it strips the the newlines (and doesn't leave a newline at the end). For more info see https://stackoverflow.com/a/21699210/3217306

- name: Running all tests
  if: >-
    startsWith(github.event.comment.body, '/run-e2e-all') ||
    startsWith(github.event.comment.body, '/run-e2e-first-test') ||
    startsWith(github.event.comment.body, '/run-e2e-second-test') ||
    startsWith(github.event.comment.body, '/run-e2e-third-test')
  # etc.
  run: |
    echo "Hello all"

from request-action.

sodre avatar sodre commented on August 22, 2024 9

I tried many routes, what ended up working for me is adding an additional | to tell yaml.safeLoad, that it is actually reading a multi-line string.

...
  body: |
    |
    My muti-line comment
      - [ ] a
      - [ ] b
...

from request-action.

uditgaurav avatar uditgaurav commented on August 22, 2024 6

A similar type of issue I'm facing:
My if condition is very larger in size and I want to write it in multiple lines. Is there any way to do that?

      - name: Running all tests
        if: startsWith(github.event.comment.body, '/run-e2e-all') || startsWith(github.event.comment.body, '/run-e2e-first-test') || startsWith(github.event.comment.body, '/run-e2e-second-test') || startsWith(github.event.comment.body, '/run-e2e-third-test') || startsWith(github.event.comment.body, '/run-e2e-fourth-test') || startsWith(github.event.comment.body, '/run-e2e-fifth-test') || startsWith(github.event.comment.body, '/run-e2e-sixth-test') || startsWith(github.event.comment.body, '/run-e2e-seventh-test') || startsWith(github.event.comment.body, '/run-e2e-eighth-test') || startsWith(github.event.comment.body, '/run-e2e-nineth-test') || startsWith(github.event.comment.body, '/run-e2e-tenth-test')
        run: |
          echo "Hello all"

from request-action.

sodre avatar sodre commented on August 22, 2024 1

@gr2m, I think the problem is simple to understand now. The values in the with section for octokit/request-action, are always interpreted as yaml documents, and not literally as strings.

I will try to create a simpler test case to reproduce the problem.

from request-action.

gr2m avatar gr2m commented on August 22, 2024

I'm glad you got it working! We added the yaml.safeLoad to allow parameters to be set to JSON strings, so object parameters can be supported. It sounds very odd that it removes the new lines ... your workaround looks odd to me, too. I feel like there should be proper way to do this, but I don't have the time to look into it myself right now, maybe you or someone else can dig into this?

from request-action.

nwhittaker avatar nwhittaker commented on August 22, 2024

@gr2m, since this issue is closed what is the recommended method for passing in a multi-line body? Is it still to double-up the pipe as in #6 (comment)?

from request-action.

gr2m avatar gr2m commented on August 22, 2024

Good question! I think that a single | should suffice, could you please give it a try?

from request-action.

nwhittaker avatar nwhittaker commented on August 22, 2024

Good question! I think that a single | should suffice, could you please give it a try?

I ask because I was still seeing issues with a multi-line body, but there may be an additional factor at play. For us, we're seeing an error when the multi-line body includes colon (:) characters. I'll create a new issue.

from request-action.

gr2m avatar gr2m commented on August 22, 2024

we're seeing an error when the multi-line body includes colon (:) characters. I'll create a new issue.

Ah I think I know what's happening. Yes, let's discuss in the new issue

from request-action.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.