I have this task that is supposed to add file contents to the PR comment:
- task: GitHubComment@0
inputs:
gitHubConnection: 'Github PR comment'
repositoryName: 'myrepo/'
comment: |
Validation Failed
<details>
<summary>Report Details</summary>
```xml
$(XML_REPORT)
```
</details>
condition: eq(variables['addGithubComment'], 'true')
displayName: 'Update github comment'
However, GitHub doesn't seem to add all the contents on the PR comment.
I was wondering if it's possible to attach the file directly to the comment instead of adding the file contents to the comment as text.
I have this task that is supposed to add file contents to the PR comment:
- task: GitHubComment@0
inputs:
gitHubConnection: 'Github PR comment'
repositoryName: 'myrepo/'
comment: |
Validation Failed
<details>
<summary>Report Details</summary>
```xml
$(XML_REPORT)
```
</details>
condition: eq(variables['addGithubComment'], 'true')
displayName: 'Update github comment'
However, GitHub doesn't seem to add all the contents on the PR comment.
I was wondering if it's possible to attach the file directly to the comment instead of adding the file contents to the comment as text.
I was wondering if it's possible to attach the file directly to the comment instead of adding the file contents to the comment as text.
I can reproduce the same with you with the task, currently it's not supported to attach the file directly to comment.
Directly checked on github, when you upload a file to a GitHub pull request comment, GitHub generates a unique URL for that file as below:
But there isn't a direct command or script to upload a file and get a similar link without using the GitHub web interface.
As an alternative, you can use the github repo file link instead(you can upload the file to github in previous step), so that the file is accessible in the comment.
Put the github file link in the format like [customlog.txt](https://github.com/test/temp1/blob/dev1/test.log)
- task: GitHubComment@0
inputs:
gitHubConnection: 'githubtemp'
repositoryName: 'test/temp1'
id: '2'
comment: "[customlog.txt](https://github.com/test/temp1/blob/dev1/test.log)"
It's same behavior with bash command:
- bash: |
curl -X POST -H "Authorization: token $(githubtoken)" -H "Content-Type: application/json" -d '{"body": "[customlog.txt](https://github.com/test/temp1/blob/dev1/test.log)"}' https://api.github.com/repos/test/temp1/issues/2/comments