body-file markdown formatting code block
semihural-tomtom opened this issue · comments
Semih Ural commented
I can add markdown file as an issue comment but how can I format this comment as a code block? Is that possible?
- name: Run Trivy vulnerability scanner in repo mode
uses: aquasecurity/trivy-action@master
with:
image-ref: ''
scan-type: 'fs'
format: 'table'
exit-code: '0'
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'CRITICAL,HIGH'
output: 'trivy-result.md'
- name: Upload Trivy report
uses: actions/upload-artifact@v3
with:
path: trivy-result.md
name: trivy-result
- name: Download Trivy report
uses: actions/download-artifact@v1
with:
name: trivy-result
- name: Create comment
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ github.event.issue.number }}
body-file: 'trivy-result.md'
Peter Evans commented
There's no support for mixing markdown and files. You'll need to add a step to edit the file and wrap it in a code block with backticks.
Semih Ural commented
@peter-evans any example of how can I achieve this?
Peter Evans commented
I asked ChatGPT and this it what it give me. Not tested, but it's a starting point. 😄
- name: Wrap file contents in markdown code block
run: |
sed -i -e '1s/^/```\n/' -e '$s/$/\n```/' myfile.txt
shell: bash
Semih Ural commented
That's worked :D thanks @peter-evans