|
19 | 19 | github.event.issue.pull_request && |
20 | 20 | github.event.comment.body == '/changelog' |
21 | 21 | steps: |
22 | | - - name: Acknowledge request |
23 | | - uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 |
| 22 | + - name: Generate changelog for PR |
| 23 | + uses: Automattic/vip-actions/ai-changelog-generator@a10bde8914496b7386d10fc5df9b4ffa2fd72ef1 |
24 | 24 | with: |
25 | | - issue-number: ${{ github.event.issue.number }} |
26 | | - reactions: 'eyes' |
27 | | - comment-id: ${{ github.event.comment.id }} |
28 | | - |
29 | | - - name: Verify OpenAI API Key is available |
30 | | - run: | |
31 | | - if [ -z "${OPENAI_API_KEY}" ]; then |
32 | | - echo "OPENAI_API_KEY is not set." |
33 | | - exit 1 |
34 | | - fi |
35 | | - env: |
36 | | - OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} |
37 | | - |
38 | | - - name: Check if user has write access |
39 | | - id: check_access |
40 | | - uses: actions/github-script@v7.0.1 |
41 | | - with: |
42 | | - script: | |
43 | | - const { data: membership } = await github.rest.repos.getCollaboratorPermissionLevel({ |
44 | | - owner: context.repo.owner, |
45 | | - repo: context.repo.repo, |
46 | | - username: context.payload.comment.user.login |
47 | | - }); |
48 | | - if (membership.permission !== 'write' && membership.permission !== 'admin' && membership.permission !== 'maintain') { |
49 | | - core.setFailed(`User ${context.payload.comment.user.login} does not have write access.`); |
50 | | - } else { |
51 | | - core.setOutput("authorized", 'true'); |
52 | | - } |
53 | | -
|
54 | | - - name: Generate Changelog Entry |
55 | | - if: steps.check_access.outputs.authorized == 'true' |
56 | | - id: changelog |
57 | | - uses: Automattic/vip-actions/ai-changelog@1ca5877971f93f05fceaa0efd119c40218c1da1e # trunk |
58 | | - with: |
59 | | - pr_number: ${{ github.event.issue.number }} |
60 | 25 | openai_api_key: ${{ secrets.OPENAI_API_KEY }} |
61 | | - |
62 | | - - name: Find Comment |
63 | | - uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0 |
64 | | - if: steps.check_access.outputs.authorized == 'true' |
65 | | - id: fc |
66 | | - with: |
67 | | - issue-number: ${{ github.event.issue.number }} |
68 | | - comment-author: 'github-actions[bot]' |
69 | | - body-includes: '## AI-Generated Changelog Entry' |
70 | | - direction: last |
71 | | - |
72 | | - - name: Post Changelog Comment |
73 | | - if: > |
74 | | - steps.check_access.outputs.authorized == 'true' && |
75 | | - steps.changelog.outputs.changelog_entry |
76 | | - uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 |
77 | | - with: |
78 | | - issue-number: ${{ github.event.issue.number }} |
79 | | - body: | |
80 | | - ## AI-Generated Changelog Entry |
81 | | -
|
82 | | - ${{ steps.changelog.outputs.changelog_entry }} |
83 | | -
|
84 | | - comment-id: ${{ steps.fc.outputs.comment-id }} |
85 | | - edit-mode: replace |
86 | | - |
87 | | - - name: Set status (success) |
88 | | - uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 |
89 | | - if: success() |
90 | | - with: |
91 | | - issue-number: ${{ github.event.issue.number }} |
92 | | - reactions: 'hooray' |
93 | | - comment-id: ${{ github.event.comment.id }} |
94 | | - reactions-edit-mode: replace |
95 | | - |
96 | | - - name: Set status (failure) |
97 | | - uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 |
98 | | - if: failure() |
99 | | - with: |
100 | | - issue-number: ${{ github.event.issue.number }} |
101 | | - reactions: '-1' |
102 | | - comment-id: ${{ github.event.comment.id }} |
103 | | - reactions-edit-mode: replace |
0 commit comments