-
Notifications
You must be signed in to change notification settings - Fork 3.4k
61 lines (54 loc) · 2.35 KB
/
generate-pr-description.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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@v3
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
})