Handle assistant messages with 'tool_calls' #1598
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Analysis | |
on: | |
pull_request_target | |
jobs: | |
comment: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Rust and Cargo | |
run: | | |
curl -sSf https://sh.rustup.rs | sh -s -- -y | |
source $HOME/.cargo/env | |
- name: Install Tokei | |
run: cargo install tokei | |
- name: Run Tokei and get the lines of code | |
run: tokei . > tokei_output.txt | |
- name: Comment or Update PR | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const fs = require('fs'); | |
const tokeiOutput = fs.readFileSync('tokei_output.txt', 'utf8'); | |
const uniqueIdentifier = 'Code Metrics Report'; | |
const codeReport = ` | |
<details> | |
<summary>${uniqueIdentifier}</summary> | |
<pre> | |
${tokeiOutput} | |
</pre> | |
</details> | |
`; | |
const issue_number = context.issue.number; | |
const { owner, repo } = context.repo; | |
const comments = await github.rest.issues.listComments({ | |
issue_number, | |
owner, | |
repo | |
}); | |
const existingComment = comments.data.find(comment => comment.body.includes(uniqueIdentifier)); | |
if (existingComment) { | |
await github.rest.issues.updateComment({ | |
owner, | |
repo, | |
comment_id: existingComment.id, | |
body: codeReport | |
}); | |
} else { | |
await github.rest.issues.createComment({ | |
issue_number, | |
owner, | |
repo, | |
body: codeReport | |
}); | |
} |