mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 10:58:56 +00:00
122 lines
4.1 KiB
YAML
122 lines
4.1 KiB
YAML
name: Comment
|
|
|
|
permissions:
|
|
actions: read
|
|
pull-requests: write
|
|
|
|
on:
|
|
workflow_run:
|
|
workflows:
|
|
- CI
|
|
types:
|
|
- completed
|
|
|
|
jobs:
|
|
comment:
|
|
if: ${{ github.repository_owner == 'oven-sh' }}
|
|
name: Comment
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Download Tests
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: bun
|
|
pattern: bun-*-tests
|
|
github-token: ${{ github.token }}
|
|
run-id: ${{ github.event.workflow_run.id }}
|
|
- name: Setup Environment
|
|
id: env
|
|
shell: bash
|
|
run: |
|
|
echo "pr-number=$(<bun/bun-linux-x64-tests/pr-number.txt)" >> $GITHUB_OUTPUT
|
|
- name: Generate Comment
|
|
run: |
|
|
cat bun/bun-*-tests/comment.md > comment.md
|
|
if [ -s comment.md ]; then
|
|
echo -e "❌ @${{ github.actor }}, your commit has failing tests :(\n\n$(cat comment.md)" > comment.md
|
|
else
|
|
echo -e "✅ @${{ github.actor }}, all tests passed!" > comment.md
|
|
fi
|
|
echo -e "\n**[View logs](https://github.com/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }})**" >> comment.md
|
|
echo -e "<!-- generated-comment workflow=${{ github.workflow }} -->" >> comment.md
|
|
- name: Find Comment
|
|
id: comment
|
|
uses: peter-evans/find-comment@v3
|
|
with:
|
|
issue-number: ${{ steps.env.outputs.pr-number }}
|
|
comment-author: github-actions[bot]
|
|
body-includes: <!-- generated-comment workflow=${{ github.workflow }} -->
|
|
- name: Write Comment
|
|
uses: peter-evans/create-or-update-comment@v4
|
|
with:
|
|
comment-id: ${{ steps.comment.outputs.comment-id }}
|
|
issue-number: ${{ steps.env.outputs.pr-number }}
|
|
body-path: comment.md
|
|
edit-mode: replace
|
|
comment-lint:
|
|
if: ${{ github.repository_owner == 'oven-sh' }}
|
|
name: Comment
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Download Comment
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: format.log
|
|
github-token: ${{ github.token }}
|
|
run-id: ${{ github.event.workflow_run.id }}
|
|
- name: PR Number
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: pr-number.txt
|
|
github-token: ${{ github.token }}
|
|
run-id: ${{ github.event.workflow_run.id }}
|
|
- name: PR Number
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: did_fail.txt
|
|
github-token: ${{ github.token }}
|
|
run-id: ${{ github.event.workflow_run.id }}
|
|
- name: Setup Environment
|
|
id: env
|
|
shell: bash
|
|
run: |
|
|
# Copy to outputs
|
|
echo "pr-number=$(<pr-number.txt)" >> $GITHUB_OUTPUT
|
|
echo "text_output=$(<format.log)" >> $GITHUB_OUTPUT
|
|
echo "did_fail=$(<did_fail.txt)" >> $GITHUB_OUTPUT
|
|
|
|
- name: Find Comment
|
|
id: comment
|
|
uses: peter-evans/find-comment@v3
|
|
with:
|
|
issue-number: ${{ steps.env.outputs.pr-number }}
|
|
comment-author: github-actions[bot]
|
|
body-includes: <!-- generated-comment workflow=${{ github.workflow }} -->
|
|
- name: Update Comment
|
|
uses: peter-evans/create-or-update-comment@v4
|
|
if: steps.env.outputs.did_fail != '0'
|
|
with:
|
|
comment-id: ${{ steps.comment.outputs.comment-id }}
|
|
issue-number: ${{ steps.env.outputs.pr-number }}
|
|
body: |
|
|
@${{ github.actor }}, C++ linting failed!
|
|
|
|
Logs:
|
|
```cpp
|
|
${{ steps.env.outputs.text_output }}
|
|
```
|
|
|
|
<!-- generated-comment workflow=${{ github.workflow }} -->
|
|
edit-mode: replace
|
|
- name: Update Previous Comment
|
|
uses: peter-evans/create-or-update-comment@v4
|
|
if: steps.env.outputs.did_fail == '0' && steps.comment.outputs.comment-id != ''
|
|
with:
|
|
comment-id: ${{ steps.comment.outputs.comment-id }}
|
|
issue-number: ${{ steps.env.outputs.pr-number }}
|
|
body: |
|
|
@${{ github.actor }}, C++ lint errors fixed! Thank you.
|
|
|
|
<!-- generated-comment workflow=${{ github.workflow }} -->
|
|
edit-mode: replace
|