Skip to content

Commit

Permalink
Adding Generate PR Description workflow (#18)
Browse files Browse the repository at this point in the history
This adds a PR comment-triggered workflow that uses the action [mkarle/skonsole-generate-pr-description](https://github.com/mkarle/skonsole-generate-pr-description).  That action uses [mkarle/pr-update](https://github.com/mkarle/pr-update) to update the PR.
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.](mkarle#4)

You'll need to add the following environment variables to the repo:
- variable: AZURE_OPENAI_CHAT_DEPLOYMENT_NAME
- secret: AZURE_OPENAI_API_ENDPOINT
- secret: AZURE_OPENAI_API_KEY
  • Loading branch information
mkarle authored Sep 18, 2023
1 parent 595e502 commit 8145ea0
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/generate-pr-description.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Generate PR Description

# Usage: Comment on a pull request with "/sk generate-pr-description <suffix(default) | prefix | replace>"

on:
issue_comment:
types: [created]

jobs:
generate-pr-description:
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.AZURE_OPENAI_CHAT_DEPLOYMENT_NAME }}
AZURE_OPENAI_API_ENDPOINT: ${{ secrets.AZURE_OPENAI_API_ENDPOINT }}
AZURE_OPENAI_API_KEY: ${{ secrets.AZURE_OPENAI_API_KEY }}

- 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
})

0 comments on commit 8145ea0

Please sign in to comment.