multiline Body not working
we would like to reference by commit message convention to have related tickets autoclosed
- name: get the PR body
run: |
echo "👑 *An automated PR* 👑\n\n" > pr_msg
git log origin/master..origin/staging --no-merges --pretty='format:%s' > diff
cat diff | grep -oP '\[#[0-9]{4,5}\]' | grep -v "0000" | grep -oP '\#[0-9]{4,5}' >> pr_msg
sed -i 's/#/closes #/g' pr_msg
⬆️ this works great and produces a file like
closes #1234
closes #9854
closes #1235
We continue to grab it via actions and then reuse it in the PR Body
- name: Get message
id: vars
run: echo ::set-output name=pr_body::$(cat pr_msg)
...
source_branch: ${{ steps.branch.outputs.name }}
destination_branch: "master"
pr_title: "🚢 ${{ steps.branch.outputs.name }} - SHIP IT :shipit:"
pr_body: ${{ steps.vars.outputs.pr_body }}
What would be the correct way of having the new lines respected?
There is currently an open PR for this https://github.com/repo-sync/pull-request/pull/89
thanks @wei
it didn't fixed it.
@wei I forked, merged the PR #89 into our master and used it. the result is this:
branch i used: https://github.com/dcflw/pull-request/commits/master
It seems to be working in https://github.com/Telefonica/mistica-icons/blob/8ece560530b0277eb0bd41aaddfc507d9ddf3dae/.github/workflows/figma-export.yml#L284-L286
Example PR: https://github.com/Telefonica/mistica-icons/pull/233
Can you wrap it with quotes similar to the one in the comment?
i will give it a try tomorrow!
i'll try this now . will feedback.
still not working. more details here: https://github.com/repo-sync/pull-request/pull/89#issuecomment-1301282166
@krtschmr Here is a another simple working example:
Code: https://github.com/wei/test-pr/blob/15f57cc1439fde8185f60a4cd3455c6a0c1a7e1b/.github/workflows/pr.yml#L17-L20 Pull Request: https://github.com/wei/test-pr/pull/11
I don't know how your string is constructed I recommend reading more about how yml treats your string. https://yaml-multiline.info/
Alternatively:
thanks. i didn't know about yaml multiline foo. will try now
pr_body: |
${{ steps.vars.outputs.pr_body }}
this also doesn't work for us. the string itself contains multiple \n but the outcome is still. no matter what syntax on yaml i use.
As per my screenshot in the last comment, the string needs to contain actual line breaks instead of the text "\n". Can you verify that is the case in the output variable you created?
then i understand. so we cannot pass strings, containing \n. then this issue is settled. or actually another issue, maybe worth adressing?
I don't believe this is another issue as it's working as expected from my testing above.
You just need to pass pr body string containing actual line breaks as seen in the examples I provided.
i mean, yes, those are line breaks.
it's also not really important to us actually. ruby puts(array) does also add new lines and then we have the closes XZY just in one line rather than multilines. it still works and creating the PR is awesome 🥳
Thanks for bareing with me. Found the root cause as GitHub actions is truncating multiline outputs.
ref: https://github.com/community/community/discussions/26288
Also, the way you set output variable is being deprecated. It will likely be fixed once you update how you set your output.
ref: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
allright. i saw the deprecation but never looked into it yet. writing key=valyue into one object sounds way easier. i'll give it a shot in the near future and report back to you. thanks for your effort!