mirror of
https://github.com/microsoft/semantic-kernel.git
synced 2026-10-12 02:19:06 +00:00
Adding skonsole workflow to generate PR descriptions. (#2865)
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> This adds a PR comment-triggered workflow that uses the action [mkarle/skonsole-generate-pr-description](https://github.com/mkarle/skonsole-generate-pr-description) to run skonsole on the diff of the PR. That action uses [mkarle/pr-update](https://github.com/mkarle/pr-update) to update the PR with a title, a summary, and a list of changes. It can update as a prefix, suffix, or entirely replace what's there. ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> To use, create a comment on a PR with: `/sk generate-pr-description <suffix(default) | prefix | replace>` Since it's triggered from a pull request comment, it only runs if it's in the default branch of the repo. [See this PR for an example of it working.](https://github.com/mkarle/skonsole/pull/4) ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [ ] The code builds clean without any errors or warnings - [ ] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [ ] All unit tests pass, and I have added new tests where possible - [ ] I didn't break anyone 😄
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
name: Generate PR Description
|
||||
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
generate-pr-description:
|
||||
permissions:
|
||||
pull-requests: write
|
||||
statuses: write
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event.issue.pull_request && contains(github.event.comment.body, '/sk generate-pr-description')
|
||||
steps:
|
||||
- name: Get PR branch
|
||||
uses: xt0rted/pull-request-comment-branch@v1
|
||||
id: comment-branch
|
||||
|
||||
- name: Set latest commit status as pending
|
||||
uses: myrotvorets/set-commit-status-action@master
|
||||
with:
|
||||
sha: ${{ steps.comment-branch.outputs.head_sha }}
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: pending
|
||||
|
||||
- name: Generate PR description
|
||||
uses: mkarle/skonsole-generate-pr-description@v1
|
||||
with:
|
||||
pull-request-number: ${{ github.event.issue.number }}
|
||||
pull-request-diff-url: ${{ github.event.issue.pull_request.diff_url }}
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
update-type: ${{ contains(github.event.comment.body, 'replace') && 'replace' || (contains(github.event.comment.body, 'prefix') && 'prefix' || 'suffix') }}
|
||||
env: # Set Azure credentials secret as an input
|
||||
AZURE_OPENAI_CHAT_DEPLOYMENT_NAME: ${{ vars.AZUREOPENAI__CHAT__DEPLOYMENTNAME }}
|
||||
AZURE_OPENAI_API_ENDPOINT: ${{ secrets.AZUREOPENAI__ENDPOINT }}
|
||||
AZURE_OPENAI_API_KEY: ${{ secrets.AZUREOPENAI__APIKEY }}
|
||||
|
||||
- name: Set latest commit status as ${{ job.status }}
|
||||
uses: myrotvorets/set-commit-status-action@master
|
||||
if: always()
|
||||
with:
|
||||
sha: ${{ steps.comment-branch.outputs.head_sha }}
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
status: ${{ job.status }}
|
||||
|
||||
- name: Add comment to PR
|
||||
uses: actions/github-script@v6
|
||||
if: always()
|
||||
with:
|
||||
script: |
|
||||
const name = '${{ github.workflow }}';
|
||||
const url = '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}';
|
||||
const success = '${{ job.status }}' === 'success';
|
||||
const body = `${name}: ${success ? 'succeeded ✅' : 'failed ❌'}\n${url}`;
|
||||
|
||||
await github.rest.issues.createComment({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: body
|
||||
})
|
||||
Reference in New Issue
Block a user