Code Monkey home page Code Monkey logo

Comments (3)

peter-evans avatar peter-evans commented on September 22, 2024 3

@hwhsu1231 Sorry, I misunderstood what you were trying to do.

You can handle multiline content from a file into a step variable like this.

      - id: get-commit-message
        run: |
          body=$(cat commit-message.txt)
          delimiter="$(openssl rand -hex 8)"
          echo "body<<$delimiter" >> $GITHUB_OUTPUT
          echo "$body" >> $GITHUB_OUTPUT
          echo "$delimiter" >> $GITHUB_OUTPUT

      - name: Create Pull Request
        uses: peter-evans/create-pull-request@v4
        with:
          body: ${{ steps.get-commit-message.outputs.body }}

Just make sure you format the commit-message.txt file correctly. The first line is the "title," then leave one blank line before the "description."

commit message title

commit message body which can be multiline
another line
Some JSON:
{
  "test": "test",
  "test2": "test2"
}

from create-pull-request.

peter-evans avatar peter-evans commented on September 22, 2024

Hi @hwhsu1231

The commit-message input works the same as it does in git. If you leave a blank line after the message, anything else will populate the commit message description.

e.g.

          commit-message: |
            Add report file

            This is a test commit message body.
            You can use multiple lines.
            Some JSON:
            {
              "test": "test",
              "test2": "test2"
            }

image

Hope that helps you with what you are trying to do.

from create-pull-request.

hwhsu1231 avatar hwhsu1231 commented on September 22, 2024

Hello, @peter-evans

That's not what I want! According to the demo you provided:

          commit-message: |
            Add report file

            This is a test commit message body.
            You can use multiple lines.
            Some JSON:
            {
              "test": "test",
              "test2": "test2"
            }

That means the JSON content will be hardcoded into the commit message whenver the PR is created by this GitHub Workflow.

However, in my consideration, the content of source.json will be updated continuously. Or should I say source.json file will be updated due to this GitHub Workflow is triggered.

That's why I need to extract some information from source.json file and record them into the commit message of the PR.

from create-pull-request.

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.