Skip to content

Update RPCN Connector Docs #52

Update RPCN Connector Docs

Update RPCN Connector Docs #52

Workflow file for this run

name: Update RPCN Connector Docs
on:
workflow_dispatch:
repository_dispatch: # Allows other repositories to trigger this workflow
types: [generate-rpcn-docs]
jobs:
generate-docs-and-submit-pull-request:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
# Allow concurrent runs
concurrency:
group: update-rpcn-connector-docs
cancel-in-progress: false
env:
NODE_VERSION: '24'
DOCS_OVERRIDES: docs-data/overrides.json
AUTO_BRANCH: auto-docs/update-rpcn-connector-docs
steps:
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ${{ vars.RP_AWS_CRED_REGION }}
role-to-assume: arn:aws:iam::${{ secrets.RP_AWS_CRED_ACCOUNT_ID }}:role/${{ vars.RP_AWS_CRED_BASE_ROLE_NAME }}${{ github.event.repository.name }}
- uses: aws-actions/aws-secretsmanager-get-secrets@v2
with:
secret-ids: |
,sdlc/prod/github/actions_bot_token
parse-json-secrets: true
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ env.ACTIONS_BOT_TOKEN }}
fetch-depth: 0 # Full history for rebasing
- name: Check for existing PR branch and set up workspace
id: setup
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Check if the auto-docs branch exists on remote
if git ls-remote --heads origin $AUTO_BRANCH | grep -q "$AUTO_BRANCH"; then
echo "branch_exists=true" >> "$GITHUB_OUTPUT"
echo "Found existing branch $AUTO_BRANCH"
# Fetch and checkout the existing branch
git fetch origin $AUTO_BRANCH
git checkout $AUTO_BRANCH
# Rebase on main to get latest changes
if git rebase origin/main; then
echo "rebase_success=true" >> "$GITHUB_OUTPUT"
echo "Successfully rebased on main"
else
echo "rebase_success=false" >> "$GITHUB_OUTPUT"
echo "Rebase failed - will handle conflicts"
git rebase --abort
# Stay on the branch but note we couldn't rebase
fi
# Check for manual commits (commits not from the bot)
MANUAL_COMMITS=$(git log origin/main..$AUTO_BRANCH --author="^(?!github-actions).*" --perl-regexp --oneline | head -20)
if [ -n "$MANUAL_COMMITS" ]; then
echo "has_manual_commits=true" >> "$GITHUB_OUTPUT"
echo "Found manual commits:"
echo "$MANUAL_COMMITS"
# Save the list for the PR body
{
echo "manual_commits<<EOF"
echo "$MANUAL_COMMITS"
echo "EOF"
} >> "$GITHUB_OUTPUT"
else
echo "has_manual_commits=false" >> "$GITHUB_OUTPUT"
fi
else
echo "branch_exists=false" >> "$GITHUB_OUTPUT"
echo "has_manual_commits=false" >> "$GITHUB_OUTPUT"
echo "rebase_success=true" >> "$GITHUB_OUTPUT"
echo "Branch $AUTO_BRANCH does not exist, will create new"
# Create new branch from main
git checkout -b $AUTO_BRANCH
fi
- name: Set up Node.js (with npm cache)
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Wait for registry update
run: sleep 500
- name: Install dependencies
run: npm install
- name: Install tools
run: |
npx --no-install doc-tools install-test-dependencies
rpk connect install
- name: Generate RPCN Connector docs
id: generate
run: |
npx --no-install doc-tools generate rpcn-connector-docs \
--fetch-connectors \
--overrides $DOCS_OVERRIDES \
--draft-missing \
--update-whats-new > full_output.txt
# Extract PR summary (between <!-- PR_SUMMARY_START --> and <!-- PR_SUMMARY_END -->)
if grep -q "PR_SUMMARY_START" full_output.txt; then
sed -n '/<!-- PR_SUMMARY_START -->/,/<!-- PR_SUMMARY_END -->/p' full_output.txt > pr_summary.txt
echo "PR summary extracted"
else
echo " No PR summary found in output"
touch pr_summary.txt
fi
{
echo "delta_report<<EOF"
# Include PR summary at the top if it exists
if [ -s pr_summary.txt ]; then
cat pr_summary.txt
echo ""
echo "---"
echo ""
fi
echo "For help reviewing this content, see our [wiki](https://redpandadata.atlassian.net/wiki/spaces/DOC/pages/1247543314/Review+autogenerated+reference+docs+for+Redpanda+Connect)."
echo ""
echo "<details><summary>📋 Full Generation Output</summary>"
echo ""
echo '```'
cat full_output.txt
echo '```'
echo ""
echo "</details>"
echo "EOF"
} >> "$GITHUB_OUTPUT"
rm -f full_output.txt pr_summary.txt
- name: Check for changes
id: changes
run: |
if git diff --quiet && git diff --staged --quiet; then
echo "has_changes=false" >> "$GITHUB_OUTPUT"
echo "No changes detected"
else
echo "has_changes=true" >> "$GITHUB_OUTPUT"
echo "Changes detected:"
git status --short
fi
- name: Commit and push changes
if: steps.changes.outputs.has_changes == 'true'
id: commit
run: |
git add -A
# Create commit message with timestamp for tracking
TIMESTAMP=$(date -u +"%Y-%m-%d %H:%M UTC")
git commit -m "docs: Update RPCN connector docs
Auto-generated at $TIMESTAMP"
# Push to the branch
if git push origin $AUTO_BRANCH --force-with-lease; then
echo "push_success=true" >> "$GITHUB_OUTPUT"
else
echo "push_success=false" >> "$GITHUB_OUTPUT"
echo "Push failed - likely a concurrent update. Will retry."
# Fetch latest and try to rebase our commit
git fetch origin $AUTO_BRANCH
if git rebase origin/$AUTO_BRANCH; then
git push origin $AUTO_BRANCH --force-with-lease
echo "push_success=true" >> "$GITHUB_OUTPUT"
else
echo "push_success=false" >> "$GITHUB_OUTPUT"
git rebase --abort
fi
fi
- name: Create or Update Pull Request
if: steps.changes.outputs.has_changes == 'true' && steps.commit.outputs.push_success == 'true'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ env.ACTIONS_BOT_TOKEN }}
base: main
branch: ${{ env.AUTO_BRANCH }}
title: 'auto-docs: Update RPCN connector docs'
commit-message: 'docs: Update RPCN connector docs'
body: |
${{ steps.generate.outputs.delta_report }}
${{ steps.setup.outputs.has_manual_commits == 'true' && format('
---
⚠️ **This PR contains manual commits that have been preserved:**
```
{0}
```
The automation has added new changes on top of these manual edits.
', steps.setup.outputs.manual_commits) || '' }}
labels: auto-docs
# Don't delete branch on merge - let the normal PR process handle it
delete-branch: false
- name: Handle no changes
if: steps.changes.outputs.has_changes == 'false'
run: |
echo "No documentation changes detected. This could mean:"
echo "- The connector docs are already up to date"
echo "- The generation produced identical output"
echo ""
if [ "${{ steps.setup.outputs.branch_exists }}" == "true" ]; then
echo "Existing PR branch preserved with any manual changes intact."
fi
- name: Handle push failure
if: steps.changes.outputs.has_changes == 'true' && steps.commit.outputs.push_success == 'false'
run: |
echo "::error::Failed to push changes after retry. This usually means:"
echo "- Another automation run is in progress"
echo "- There are unresolvable conflicts"
echo ""
echo "Manual intervention may be required."
exit 1