|
5 | 5 | schedule: |
6 | 6 | - cron: "15 22 * * *" |
7 | 7 |
|
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + models: read |
| 11 | + |
8 | 12 | jobs: |
9 | 13 | update: |
10 | 14 | runs-on: ubuntu-latest |
|
24 | 28 | run: bundle exec rake api:validate |
25 | 29 | - name: Get current date |
26 | 30 | run: echo "CURRENT_DATE=$(date +%Y/%m/%d)" >> $GITHUB_ENV |
| 31 | + - name: Check for changes |
| 32 | + id: changes |
| 33 | + run: | |
| 34 | + if git diff --quiet; then |
| 35 | + echo "changed=false" >> "$GITHUB_OUTPUT" |
| 36 | + else |
| 37 | + echo "changed=true" >> "$GITHUB_OUTPUT" |
| 38 | + fi |
| 39 | + - name: Prepare diff for AI summary |
| 40 | + if: steps.changes.outputs.changed == 'true' |
| 41 | + run: | |
| 42 | + git diff --stat > /tmp/diff_stat.txt |
| 43 | + git diff | head -c 20000 > /tmp/diff.txt |
| 44 | + - name: Generate commit message with AI |
| 45 | + if: steps.changes.outputs.changed == 'true' |
| 46 | + id: ai |
| 47 | + uses: actions/ai-inference@v1 |
| 48 | + with: |
| 49 | + prompt-file: ./.github/prompts/commit-message.prompt.yml |
| 50 | + file_input: | |
| 51 | + diff_stat: /tmp/diff_stat.txt |
| 52 | + diff: /tmp/diff.txt |
| 53 | + - name: Build commit message |
| 54 | + id: message |
| 55 | + run: | |
| 56 | + title="" |
| 57 | + summary="" |
| 58 | + if [ "${{ steps.changes.outputs.changed }}" = "true" ]; then |
| 59 | + title="$(jq -r '.title // empty' "${{ steps.ai.outputs.response-file }}" 2>/dev/null)" |
| 60 | + summary="$(jq -r '.summary // empty' "${{ steps.ai.outputs.response-file }}" 2>/dev/null)" |
| 61 | + fi |
| 62 | + if [ -z "$title" ]; then |
| 63 | + title="Updated from Slack docs, ${CURRENT_DATE}" |
| 64 | + summary="" |
| 65 | + fi |
| 66 | + { |
| 67 | + echo 'message<<COMMIT_MESSAGE_EOF' |
| 68 | + echo "$title" |
| 69 | + echo "" |
| 70 | + echo "$summary" |
| 71 | + echo 'COMMIT_MESSAGE_EOF' |
| 72 | + } >> "$GITHUB_OUTPUT" |
27 | 73 | - name: Commit changes |
28 | 74 | uses: EndBug/add-and-commit@v9 |
29 | 75 | with: |
30 | 76 | author_name: Slack API Ref Buildbot |
31 | 77 | author_email: buildbot@slack-api-ref.com |
32 | | - message: "Updated from Slack docs, ${{ env.CURRENT_DATE }}" |
| 78 | + message: ${{ steps.message.outputs.message }} |
0 commit comments