-
-
Notifications
You must be signed in to change notification settings - Fork 439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide a 'commit-message-body' field? #2634
Comments
Hi @hwhsu1231 The 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"
} Hope that helps you with what you are trying to do. |
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 That's why I need to extract some information from |
@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
|
Subject of the issue
Hello, create-pull-request Development Team.
From the README.md, I understand that we can customize the PR Description using either the
body
orbody-path
field, but there is only acommit-message
field for customizing the content of the Commit Message.If possible, I hope it can provide a
commit-message-body
field as well.Here's why I'm requesting this.
(1) Storing Formatted JSON Objects
I want to read a specific object (.object) from a JSON file (source.json) and make it accessible to subsequent steps.
However, I found many problems when trying to store a formatted JSON object via an environment variable, mainly because the formatted JSON object contains newline characters
\n
.After some attempts, my solution was:
cat
command to read the entire content of thesource.json
file.jq
command to query the JSON object I want.sed
command to replace\\n
with\n
.JSON_OBJ
.echo
command to print the content of this environment variable to a new file,json-obj.txt
.If needed later, it can be read using
$(<json-obj.txt)
. Here is a simple demonstration:(2) Wanting to Include json-obj.txt in the PR's Description or Commit Message
Furthermore, if I want to include the contents of
json-obj.txt
in the Description or Commit Message of the PR I'm creating. For example, the following content:I found that I couldn't use
$(<json-obj.txt)
in thebody
orcommit-message
fields. So, I first saved the content I wanted for the Description to a file namedbody.txt
. Then I used thebody-path
field to specify thebody.txt
file as the content for the Description. The implementation is as follows:But since create-pull-request only provides a
body-path
, this method can only be applied to the PR Description.That's why I hope create-pull-request could provide a
commit-message-body
field.The text was updated successfully, but these errors were encountered: