Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/prompts/changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Generate a concise single-line changelog entry for this PR.

Requirements:
- Follow conventional commit format (feat/fix/docs/chore/refactor/etc)
- Be specific about what changed
- No markdown formatting or bullet points
- Plain text only

PR Title: {{PR_TITLE}}

PR Description: {{PR_BODY}}

Diff:
{{DIFF}}
74 changes: 70 additions & 4 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,80 @@ jobs:
echo "modified=false" >> $GITHUB_OUTPUT
fi

- name: Generate changelog suggestion
if: steps.changelog-check.outputs.modified == 'false'
id: changelog-suggestion
env:
GEMINI_KEY: ${{ secrets.GEMINI_API_KEY }}
PR_TITLE: ${{ github.event.pull_request.title }}
PR_BODY: ${{ github.event.pull_request.body }}
run: |
# Get the full diff
git fetch origin ${{ github.base_ref }}
DIFF=$(git diff origin/${{ github.base_ref }}...HEAD)

echo "Diff size: ${#DIFF} characters"

# Limit diff size to avoid token limits (roughly 100k chars = ~25k tokens)
if [ ${#DIFF} -gt 100000 ]; then
echo "Diff too large, truncating to 100k characters"
DIFF="${DIFF:0:100000}"
fi

PROMPT=$(cat .github/prompts/changelog.txt)
PROMPT="${PROMPT//\{\{PR_TITLE\}\}/$PR_TITLE}"
PROMPT="${PROMPT//\{\{PR_BODY\}\}/$PR_BODY}"
PROMPT="${PROMPT//\{\{DIFF\}\}/$DIFF}"

PAYLOAD=$(jq -n \
--arg prompt "$PROMPT" \
'{
contents: [{
parts: [{
text: $prompt
}]
}],
generationConfig: {
temperature: 0.3,
maxOutputTokens: 1000
}
}')

echo "Calling Gemini API..."
RESPONSE=$(curl -s -X POST \
"https://generativelanguage.googleapis.com/v1/models/gemini-2.5-flash:generateContent?key=$GEMINI_KEY" \
-H 'Content-Type: application/json' \
-d "$PAYLOAD")

echo "API Response:"
echo "$RESPONSE" | jq '.'

if echo "$RESPONSE" | jq -e '.error' > /dev/null; then
# Fallback to PR title if API fails
echo "API Error - using PR title as fallback"
echo "$RESPONSE" | jq '.error'
SUGGESTION="$PR_TITLE"
else
SUGGESTION=$(echo "$RESPONSE" | jq -r '.candidates[0].content.parts[0].text // ""' | tr -d '\n' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
if [ -z "$SUGGESTION" ]; then
echo "Empty suggestion received, using PR title"
SUGGESTION="$PR_TITLE"
else
echo "Generated suggestion: $SUGGESTION"
fi
fi

echo "suggestion<<EOF" >> $GITHUB_OUTPUT
echo "$SUGGESTION" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

- name: Comment if changelog is missing
if: steps.changelog-check.outputs.modified == 'false'
env:
CHANGELOG_ENTRY: ${{ steps.changelog-suggestion.outputs.suggestion }}
uses: actions/github-script@v7
with:
script: |
const prTitle = context.payload.pull_request.title;

// Check if bot already commented
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
Expand All @@ -99,11 +166,10 @@ jobs:

**Recommendation:**
\`\`\`
${prTitle}
${process.env.CHANGELOG_ENTRY}
\`\`\`

Please add an entry to the CHANGELOG.md or dismiss this if the change doesn't require documentation.

**To dismiss:** Reply with \`/skip-changelog\` in any comment.`;

await github.rest.issues.createComment({
Expand Down
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
&nbsp;&nbsp;**New env vars:**\
&nbsp;&nbsp;&nbsp;&nbsp; `stale_filter_ttl` duration in seconds before a stale filter is evicted from active filters cache\
&nbsp;&nbsp;&nbsp;&nbsp; `enable_filters` enables or disables the filter RPC endpoints (default: true)
- ci: Add Gemini API integration for changelog suggestions in PR checks

## v0.8.1 (2025-10-25)
Fixes Testnet guest list for Light Client Prover.
Expand Down Expand Up @@ -50,7 +51,7 @@ Node operators need to rescan L1:
# use citrea-cli v0.7.2
citrea-cli --rollback --node-type fullnode --db-path path/to/db --l2-target 9999999999 --l1-target 74247 --sequencer-commitment-index 0

citrea-cli clear-pending --db-path path/to/dbs
citrea-cli clear-pending --db-path path/to/dbs
```


Expand All @@ -63,7 +64,7 @@ Node operators need to rescan L1:
# use citrea-cli v0.7.1
citrea-cli --rollback --node-type fullnode --db-path path/to/db --l2-target 9999999999 --l1-target 74247 --sequencer-commitment-index 0

citrea-cli clear-pending --db-path path/to/dbs
citrea-cli clear-pending --db-path path/to/dbs
```

## v0.7.0 (2025-04-18)
Expand Down
Loading