|
| 1 | +name: '_pytorch_pr_comment' |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + repository: |
| 7 | + required: false |
| 8 | + type: string |
| 9 | + default: 'pytorch/pytorch' |
| 10 | + description: 'The full name of the repository containing the pull request' |
| 11 | + pr-number: |
| 12 | + required: true |
| 13 | + type: number |
| 14 | + description: 'The number of the pull request' |
| 15 | + pr-comment-author: |
| 16 | + required: true |
| 17 | + type: string |
| 18 | + description: 'The author of the pull request comment' |
| 19 | + secrets: |
| 20 | + pr-token: |
| 21 | + required: true |
| 22 | + description: 'A token used to create or update a pull request comment' |
| 23 | + |
| 24 | +jobs: |
| 25 | + comment: |
| 26 | + name: Create or update the pull request comment |
| 27 | + runs-on: ubuntu-latest |
| 28 | + steps: |
| 29 | + # Find the first comment containing the specified string |
| 30 | + # and by the specified author. |
| 31 | + # See: https://github.com/peter-evans/find-comment |
| 32 | + - name: Find comment |
| 33 | + uses: peter-evans/find-comment@v3 |
| 34 | + id: fc |
| 35 | + with: |
| 36 | + token: ${{ secrets.pr-token }} |
| 37 | + repository: ${{ inputs.repository }} |
| 38 | + issue-number: ${{ inputs.pr-number }} |
| 39 | + comment-author: ${{ inputs.pr-comment-author }} |
| 40 | + body-includes: '<!-- ACCELERATOR TESTINFRA START -->' |
| 41 | + direction: first |
| 42 | + |
| 43 | + - name: Show comment info |
| 44 | + run: | |
| 45 | + echo "comment id: ${{ steps.fc.outputs.comment-id }}" |
| 46 | + echo "comment node id: ${{ steps.fc.outputs.comment-node-id }}" |
| 47 | + echo "comment body: ${{ steps.fc.outputs.comment-body }}" |
| 48 | + echo "comment author: ${{ steps.fc.outputs.comment-author }}" |
| 49 | + echo "comment created at: ${{ steps.fc.outputs.comment-created-at }}" |
| 50 | +
|
| 51 | + # Create or update the comment just found. |
| 52 | + # See: https://github.com/peter-evans/create-or-update-comment |
| 53 | + - name: Create or update comment |
| 54 | + uses: peter-evans/create-or-update-comment@v4 |
| 55 | + with: |
| 56 | + token: ${{ secrets.pr-token }} |
| 57 | + repository: ${{ inputs.repository }} |
| 58 | + issue-number: ${{ inputs.pr-number }} |
| 59 | + comment-id: ${{ steps.fc.outputs.comment-id }} |
| 60 | + edit-mode: replace |
| 61 | + # TODO: use body-path instead |
| 62 | + body: | |
| 63 | + <!-- ACCELERATOR TESTINFRA START --> |
| 64 | + |
| 65 | + ## Report |
| 66 | + |
| 67 | + - something |
| 68 | + - something else |
| 69 | + |
| 70 | + <!-- ACCELERATOR TESTINFRA START --> |
0 commit comments