1
0
mirror of synced 2025-12-19 18:14:56 -05:00

ci: add autodoc-pre-merge workflow for PR documentation recommendations

Co-Authored-By: ian.alton@airbyte.io <ian.alton@airbyte.io>
This commit is contained in:
Devin AI
2025-12-18 00:54:22 +00:00
parent 000f96b8fb
commit b4fb89b90b

128
.github/workflows/autodoc-pre-merge.yml vendored Normal file
View File

@@ -0,0 +1,128 @@
# Autodoc Pre-Merge Workflow
#
# This workflow automatically comments on newly created PRs with documentation recommendations
# when a user opens a pull request that modifies connector code. It uses Devin AI to review
# the proposed changes and provide documentation guidance before the PR is merged.
#
# Workflow triggers:
# - Only on PRs opened to merge into master branch
# - Excludes bot-authored PRs to prevent automation loops
# - Only processes PRs from non-forked repos or forks with secrets access
# - Triggers for any connector changes (not filtered by support level)
name: Autodoc Pre-Merge
on:
pull_request:
types: [opened]
branches:
- master
jobs:
recommend-documentation-updates:
name: Recommend documentation updates with AI
runs-on: ubuntu-latest
# Only run for human authors, exclude bot accounts
if: |
!contains(fromJSON('["airbyteio", "octavia-bot", "octavia-bot-hoard", "github-actions[bot]", "dependabot[bot]"]'), github.actor) &&
!endsWith(github.actor, '[bot]')
steps:
# Step 1: Check if this is a fork PR without secrets access
- name: Check fork and secrets access
id: check-fork
run: |
IS_FORK="${{ github.event.pull_request.head.repo.fork }}"
echo "is_fork=$IS_FORK" >> $GITHUB_OUTPUT
# Check if we have access to secrets by checking if the Devin token is available
if [ -z "${{ secrets.DEVIN_AI_API_KEY }}" ]; then
echo "has_secrets=false" >> $GITHUB_OUTPUT
else
echo "has_secrets=true" >> $GITHUB_OUTPUT
fi
# Step 2: Exit gracefully if fork without secrets
- name: Exit if fork without secrets access
if: steps.check-fork.outputs.is_fork == 'true' && steps.check-fork.outputs.has_secrets == 'false'
run: |
echo "Cannot run Devin session for fork PRs without secrets access."
echo "This is expected behavior - fork PRs do not have access to repository secrets."
exit 0
# Step 3: Get the PR code
- name: Checkout PR code
if: steps.check-fork.outputs.is_fork != 'true' || steps.check-fork.outputs.has_secrets == 'true'
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
with:
fetch-depth: 0 # Full history needed for comprehensive analysis
# Step 4: Analyze what files were changed in this PR
- name: Get files changed in this PR
if: steps.check-fork.outputs.is_fork != 'true' || steps.check-fork.outputs.has_secrets == 'true'
id: pr-files
run: |
echo "Fetching files changed in PR #${{ github.event.pull_request.number }}..."
# Get the list of changed files by comparing base and head
FILES=$(git diff --name-only origin/${{ github.event.pull_request.base.ref }}...${{ github.event.pull_request.head.sha }} | jq -R -s -c 'split("\n")[:-1]')
if [ -z "$FILES" ] || [ "$FILES" = "[]" ]; then
echo "No files changed in this PR - skipping documentation recommendations."
echo "has_changes=false" >> $GITHUB_OUTPUT
exit 0
fi
echo "Successfully fetched changed files list"
echo "files=$FILES" >> $GITHUB_OUTPUT
echo "has_changes=true" >> $GITHUB_OUTPUT
# Step 5: Check if any connector files were modified
- name: Check for connector changes
if: steps.check-fork.outputs.is_fork != 'true' || steps.check-fork.outputs.has_secrets == 'true'
id: check-connectors
run: |
echo "Checking if PR contains connector changes..."
CHANGED_FILES='${{ steps.pr-files.outputs.files }}'
if [ -z "$CHANGED_FILES" ] || [ "$CHANGED_FILES" = "[]" ]; then
echo "No changed files found"
echo "has_connector_changes=false" >> $GITHUB_OUTPUT
exit 0
fi
# Check if any files match the connector path pattern
CONNECTOR_FILES=$(echo "$CHANGED_FILES" | jq -r '.[] | select(test("^airbyte-integrations/connectors/[^/]+/"))')
if [ -z "$CONNECTOR_FILES" ]; then
echo "No connector files found in changed files - skipping documentation recommendations."
echo "has_connector_changes=false" >> $GITHUB_OUTPUT
exit 0
fi
echo "Connector changes detected - documentation recommendations needed"
echo "has_connector_changes=true" >> $GITHUB_OUTPUT
# Step 6: Skip if no connector changes
- name: Skip documentation recommendations (no connector changes)
if: (steps.check-fork.outputs.is_fork != 'true' || steps.check-fork.outputs.has_secrets == 'true') && steps.check-connectors.outputs.has_connector_changes == 'false'
run: |
echo "Skipping documentation recommendations:"
echo " - No connector changes detected in this PR"
echo " - Only PRs with connector changes trigger documentation recommendations"
# Step 7: Trigger AI documentation recommendations for connector PRs
- name: Start AI documentation recommendation session
if: (steps.check-fork.outputs.is_fork != 'true' || steps.check-fork.outputs.has_secrets == 'true') && steps.check-connectors.outputs.has_connector_changes == 'true'
env:
PROMPT_TEXT: "PR #${{ github.event.pull_request.number }} has been opened with connector changes. Please review and provide documentation recommendations."
uses: aaronsteers/devin-action@0d74d6d9ff1b16ada5966dc31af53a9d155759f4 # Pinned to specific commit for security
with:
devin-token: ${{ secrets.DEVIN_AI_API_KEY }}
github-token: ${{ secrets.GITHUB_TOKEN }}
playbook-macro: "!autodoc-pre-merge" # Use the pre-merge documentation playbook
prompt-text: ${{ env.PROMPT_TEXT }}
tags: |
area/documentation
team/documentation