Browse Source

refactor(workflow): streamline payload validation and enhance release notes processing in update-studio-docs workflow

pull/24811/head
selmankoc 1 day ago
parent
commit
042faacb3c
  1. 137
      .github/workflows/update-studio-docs.yml

137
.github/workflows/update-studio-docs.yml

@ -14,41 +14,25 @@ jobs:
steps: steps:
# ----------------------------- # -----------------------------
# Validate payload # Validate payload (safe)
# ----------------------------- # -----------------------------
- name: Validate payload - name: Validate payload
run: | run: |
if [ -z "${{ github.event.client_payload.version }}" ]; then required_keys=(version name notes url target_branch)
echo "Missing payload field: version" for key in "${required_keys[@]}"; do
exit 1 value="$(jq -r --arg k "$key" '.client_payload[$k] // ""' "$GITHUB_EVENT_PATH")"
fi if [ -z "$value" ] || [ "$value" = "null" ]; then
echo "Missing payload field: $key"
if [ -z "${{ github.event.client_payload.name }}" ]; then exit 1
echo "Missing payload field: name" fi
exit 1 done
fi
if [ -z "${{ github.event.client_payload.notes }}" ]; then
echo "Missing payload field: notes"
exit 1
fi
if [ -z "${{ github.event.client_payload.url }}" ]; then
echo "Missing payload field: url"
exit 1
fi
if [ -z "${{ github.event.client_payload.target_branch }}" ]; then
echo "Missing payload field: target_branch"
exit 1
fi
# ----------------------------- # -----------------------------
# Checkout dev # Checkout target branch
# ----------------------------- # -----------------------------
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
ref: dev ref: ${{ github.event.client_payload.target_branch }}
fetch-depth: 0 fetch-depth: 0
- name: Configure git - name: Configure git
@ -67,47 +51,46 @@ jobs:
echo "BRANCH=$BRANCH" >> $GITHUB_ENV echo "BRANCH=$BRANCH" >> $GITHUB_ENV
# ----------------------------- # -----------------------------
# Analyze existing release-notes style # Prepare raw release notes
# ----------------------------- # -----------------------------
- name: Analyze release notes format - name: Save raw release notes
id: format
run: | run: |
FILE="docs/en/studio/release-notes.md" mkdir -p .tmp
if [ -f "$FILE" ]; then jq -r '.client_payload.notes' "$GITHUB_EVENT_PATH" > .tmp/raw-notes.txt
head -20 "$FILE" > format.txt
else
echo "## Version X.Y.Z" > format.txt
echo "- Example entry" >> format.txt
fi
echo "FORMAT<<EOF" >> $GITHUB_OUTPUT
cat format.txt >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
# ----------------------------- # -----------------------------
# AI: format release notes # Try AI formatting (optional)
# ----------------------------- # -----------------------------
- name: Generate release notes with AI - name: Generate release notes with AI (optional)
id: ai id: ai
continue-on-error: true
uses: actions/ai-inference@v1 uses: actions/ai-inference@v1
with: with:
model: openai/gpt-4.1 model: openai/gpt-4.1
prompt: | prompt: |
You are writing release notes for ABP Studio documentation. You are a technical writer.
Existing format example: Convert the following release notes into concise, user-facing bullet points.
${{ steps.format.outputs.FORMAT }} Rules:
- Use "-" bullets
- Keep it short and clear
- Skip internal / irrelevant details
Release info: Release notes:
Version: ${{ github.event.client_payload.version }}
Name: ${{ github.event.client_payload.name }}
Raw notes:
${{ github.event.client_payload.notes }} ${{ github.event.client_payload.notes }}
Instructions: # -----------------------------
- Extract only meaningful user-facing changes # Decide final notes (AI or fallback)
- Use bullet points starting with "- " # -----------------------------
- Be concise and professional - name: Decide final release notes
- Return ONLY bullet points run: |
if [ -n "${{ steps.ai.outputs.response }}" ]; then
echo "Using AI-formatted release notes"
echo "${{ steps.ai.outputs.response }}" > .tmp/final-notes.txt
else
echo "AI unavailable – using raw release notes"
sed 's/^/- /' .tmp/raw-notes.txt > .tmp/final-notes.txt
fi
# ----------------------------- # -----------------------------
# Update release-notes.md # Update release-notes.md
@ -117,26 +100,29 @@ jobs:
FILE="docs/en/studio/release-notes.md" FILE="docs/en/studio/release-notes.md"
VERSION="${{ github.event.client_payload.version }}" VERSION="${{ github.event.client_payload.version }}"
NAME="${{ github.event.client_payload.name }}" NAME="${{ github.event.client_payload.name }}"
URL="${{ github.event.client_payload.url }}"
mkdir -p docs/en/studio mkdir -p docs/en/studio
touch "$FILE" touch "$FILE"
if ! grep -q "## Version $VERSION" "$FILE"; then if grep -q "## Version $VERSION" "$FILE"; then
{ echo "Release notes already contain $VERSION, skipping"
echo "## Version $VERSION - $NAME" exit 0
echo ""
echo "${{ steps.ai.outputs.response }}"
echo ""
echo "[Release Link](${{ github.event.client_payload.url }})"
echo ""
echo "---"
echo ""
} | cat - "$FILE" > "$FILE.new"
mv "$FILE.new" "$FILE"
else
echo "Release notes already exist"
fi fi
{
echo "## Version $VERSION - $NAME"
echo ""
cat .tmp/final-notes.txt
echo ""
echo "[Release Link]($URL)"
echo ""
echo "---"
echo ""
} | cat - "$FILE" > "$FILE.new"
mv "$FILE.new" "$FILE"
# ----------------------------- # -----------------------------
# Update version-mapping.md # Update version-mapping.md
# ----------------------------- # -----------------------------
@ -156,7 +142,7 @@ jobs:
fi fi
# ----------------------------- # -----------------------------
# Detect changes # Check for changes
# ----------------------------- # -----------------------------
- name: Check for changes - name: Check for changes
id: changes id: changes
@ -181,17 +167,15 @@ jobs:
# Create PR # Create PR
# ----------------------------- # -----------------------------
- name: Create PR - name: Create PR
id: pr
if: steps.changes.outputs.has_changes == 'true' if: steps.changes.outputs.has_changes == 'true'
env: env:
GH_TOKEN: ${{ secrets.BOT_SECRET }} GH_TOKEN: ${{ secrets.BOT_SECRET }}
run: | run: |
PR_URL=$(gh pr create \ gh pr create \
--title "docs(studio): release ${{ github.event.client_payload.version }}" \ --title "docs(studio): release ${{ github.event.client_payload.version }}" \
--body "Automated ABP Studio documentation update." \ --body "Automated documentation update for ABP Studio." \
--base "${{ github.event.client_payload.target_branch }}" \ --base "${{ github.event.client_payload.target_branch }}" \
--head "$BRANCH") --head "$BRANCH"
echo "pr_url=$PR_URL" >> $GITHUB_OUTPUT
# ----------------------------- # -----------------------------
# Enable auto-merge (branch protection safe) # Enable auto-merge (branch protection safe)
@ -201,7 +185,4 @@ jobs:
env: env:
GH_TOKEN: ${{ secrets.BOT_SECRET }} GH_TOKEN: ${{ secrets.BOT_SECRET }}
run: | run: |
gh pr merge "${{ steps.pr.outputs.pr_url }}" \ gh pr merge "$BRANCH" --squash --auto --admin
--squash \
--auto \
--admin

Loading…
Cancel
Save