fix(openai): Record cached and reasoning tokens for Completions #12
This file contains hidden or 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: Enforce Draft PR | |
| on: | |
| pull_request_target: | |
| types: [opened, reopened] | |
| jobs: | |
| enforce-draft: | |
| name: Enforce Draft PR | |
| runs-on: ubuntu-24.04 | |
| if: github.event.pull_request.draft == false | |
| steps: | |
| - name: Generate GitHub App token | |
| id: app-token | |
| uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v2 | |
| with: | |
| app-id: ${{ vars.SDK_MAINTAINER_BOT_APP_ID }} | |
| private-key: ${{ secrets.SDK_MAINTAINER_BOT_PRIVATE_KEY }} | |
| - name: Convert PR to draft | |
| env: | |
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | |
| PR_URL: ${{ github.event.pull_request.html_url }} | |
| run: | | |
| gh pr ready "$PR_URL" --undo | |
| - name: Label and comment | |
| uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | |
| with: | |
| github-token: ${{ steps.app-token.outputs.token }} | |
| script: | | |
| const pullRequest = context.payload.pull_request; | |
| const repo = context.repo; | |
| // Label the PR so maintainers can filter/track violations | |
| await github.rest.issues.addLabels({ | |
| ...repo, | |
| issue_number: pullRequest.number, | |
| labels: ['converted-to-draft'], | |
| }); | |
| // Check for existing bot comment to avoid duplicates on reopen | |
| const comments = await github.rest.issues.listComments({ | |
| ...repo, | |
| issue_number: pullRequest.number, | |
| }); | |
| const botComment = comments.data.find(c => | |
| c.user.type === 'Bot' && | |
| c.body.includes('automatically converted to draft') | |
| ); | |
| if (botComment) { | |
| core.info('Bot comment already exists, skipping.'); | |
| return; | |
| } | |
| const contributingUrl = `https://github.com/${repo.owner}/${repo.repo}/blob/master/CONTRIBUTING.md`; | |
| await github.rest.issues.createComment({ | |
| ...repo, | |
| issue_number: pullRequest.number, | |
| body: [ | |
| `This PR has been automatically converted to draft. All PRs must start as drafts per our [contributing guidelines](${contributingUrl}).`, | |
| '', | |
| '**Next steps:**', | |
| '1. Ensure CI passes', | |
| '2. Fill in the PR description completely', | |
| '3. Mark as "Ready for review" when you\'re done' | |
| ].join('\n') | |
| }); |