mirror of
https://github.com/Lifailon/lazyjournal.git
synced 2026-11-11 01:09:46 +01:00
97 lines
3.1 KiB
YAML
97 lines
3.1 KiB
YAML
name: AI Release Analysis
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
Tag:
|
|
description: "Release tag name"
|
|
required: false
|
|
default: ""
|
|
release:
|
|
types: [published]
|
|
|
|
run-name: "Release ${{ inputs.Tag || github.event.release.tag_name }}"
|
|
|
|
jobs:
|
|
release_analysis:
|
|
permissions:
|
|
contents: write
|
|
models: read
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
env:
|
|
LATEST_TAG: 'head'
|
|
DIFF_DATA: ''
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Get diff from git
|
|
id: get_diff
|
|
run: |
|
|
LATEST_TAG="${{ github.event.release.tag_name }}"
|
|
if [ -z "$LATEST_TAG" ]; then
|
|
if [ -n "${{ github.event.inputs.Tag }}" ]; then
|
|
LATEST_TAG="${{ github.event.inputs.Tag }}"
|
|
else
|
|
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "head")
|
|
fi
|
|
fi
|
|
echo "LATEST_TAG=$LATEST_TAG" >> $GITHUB_ENV
|
|
PRE_TAG=$(git describe --abbrev=0 --tags "$LATEST_TAG^" 2>/dev/null || echo "")
|
|
if [ -z "$PRE_TAG" ]; then
|
|
DIFF=$(git log --oneline -n 50)
|
|
else
|
|
DIFF=$(git log "$PRE_TAG..$LATEST_TAG" --oneline)
|
|
fi
|
|
printf "DIFF_DATA<<EOF\n%s\nEOF\n" "$DIFF" >> $GITHUB_ENV
|
|
|
|
- name: Generate report using AI
|
|
id: ai_query
|
|
uses: actions/ai-inference@v2
|
|
with:
|
|
model: gpt-4.1
|
|
max-tokens: 2048
|
|
system-prompt: |
|
|
You are a technical writer.
|
|
Analyze the Git commit log and create a summary of the changes.
|
|
The summary must be in Markdown format in English and contain two key headings: "### New features" and "### Fixes"
|
|
There is no need to add a release title and commit numbers.
|
|
prompt: |
|
|
Analyze these changes for release ${{ env.LATEST_TAG }}:
|
|
${{ env.DIFF_DATA }}
|
|
|
|
- name: Push report to git
|
|
env:
|
|
AI_RESPONSE: ${{ steps.ai_query.outputs.response }}
|
|
run: |
|
|
REPORT_FILE="changelog.md"
|
|
REPORT_TEMP_FILE="changelog.tmp"
|
|
echo -e "## Release ${{ env.LATEST_TAG }}\n" > $REPORT_TEMP_FILE
|
|
echo "$AI_RESPONSE" >> $REPORT_TEMP_FILE
|
|
echo -e "\n" >> $REPORT_TEMP_FILE
|
|
if [ -f "$REPORT_FILE" ]; then
|
|
cat "$REPORT_FILE" >> $REPORT_TEMP_FILE
|
|
fi
|
|
mv $REPORT_TEMP_FILE $REPORT_FILE
|
|
git config --global user.name "github-actions"
|
|
git config --global user.email "github-actions@github.com"
|
|
git add $REPORT_FILE
|
|
git commit -m "add ai report for ${{ env.LATEST_TAG }} release"
|
|
git push
|
|
|
|
- name: Send report to Telegram
|
|
uses: appleboy/telegram-action@master
|
|
with:
|
|
token: ${{ secrets.TELEGRAM_API_TOKEN }}
|
|
to: ${{ secrets.TELEGRAM_CHANNEL_ID }}
|
|
debug: true
|
|
format: markdown
|
|
message: |
|
|
🔔 **Action**: ${{ env.LATEST_TAG }} release
|
|
|
|
${{ steps.ai_query.outputs.response }} |