name: Laravel Docs Update
permissions:
contents: write
pull-requests: write
on:
schedule:
- cron: '0 0 * * *' # Daily at midnight UTC
workflow_dispatch: # Manual trigger
jobs:
check-update:
runs-on: ubuntu-latest
outputs:
updates_available: ${{ steps.check-updates.outputs.updates_available }}
pr_number: ${{ steps.create-pr.outputs.pull-request-number }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Ensure we have latest main branch
run: |
git fetch origin main
git reset --hard origin/main
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m venv .venv
source .venv/bin/activate
pip install fastmcp mcp[cli,client] markdownify beautifulsoup4 feedparser
- name: Check for documentation updates
id: check-updates
continue-on-error: true
run: |
set +e
source .venv/bin/activate
# Run documentation update with auto-discovery enabled
echo "Starting documentation update with auto-discovery..."
python docs_updater.py --all-versions --log-level INFO
UPDATE_STATUS=$?
# Update external services documentation
echo "Updating external services documentation..."
python docs_updater.py --external-only --log-level INFO
EXTERNAL_STATUS=$?
# Check external services status to report auto-discovery results
echo "Checking external services status..."
python docs_updater.py --status --external-only
# Check if any files were actually changed
if git diff --quiet docs/; then
echo "updates_available=false" >> $GITHUB_OUTPUT
echo "No file changes detected"
else
echo "updates_available=true" >> $GITHUB_OUTPUT
echo "File changes detected"
# Count changes for reporting
CHANGED_FILES=$(git diff --name-only docs/ | wc -l)
echo "Found $CHANGED_FILES changed documentation files"
# Check for new external docs
NEW_EXTERNAL_FILES=$(git diff --name-status docs/external/ | grep "^A" | wc -l)
if [ "$NEW_EXTERNAL_FILES" -gt 0 ]; then
echo "Auto-discovery found $NEW_EXTERNAL_FILES new external documentation files"
fi
fi
- name: Close existing pull requests
if: steps.check-updates.outputs.updates_available == 'true'
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const pulls = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
head: 'update-laravel-docs'
});
for (const pull of pulls.data) {
if (pull.title === 'Update Laravel documentation' ||
pull.title === 'Update Laravel and external services documentation') {
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pull.number,
state: 'closed'
});
console.log(`Closed existing PR #${pull.number}`);
}
}
// Delete the remote branch if it exists
try {
await github.rest.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'heads/update-laravel-docs'
});
console.log('Deleted existing remote branch update-laravel-docs');
} catch (error) {
console.log('No existing remote branch to delete or error deleting:', error.message);
}
- name: Commit updated documentation
if: steps.check-updates.outputs.updates_available == 'true'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add docs/
git add docs/.metadata/
git commit -m "Update Laravel and external services documentation" || exit 0
- name: Create Pull Request
if: steps.check-updates.outputs.updates_available == 'true'
id: create-pr
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'Update Laravel and external services documentation'
title: 'Update Laravel and external services documentation'
body: |
Automated PR to update Laravel and external services documentation to the latest version.
## Auto-Discovery Status
This update includes enhancements with auto-discovery for external Laravel services:
- ✅ **Laravel Forge** - Auto-discovery enabled for comprehensive section detection
- ✅ **Laravel Vapor** - Auto-discovery enabled with Mintlify navigation parsing
- ✅ **Laravel Envoyer** - Auto-discovery enabled with redirect validation
- ✅ **Laravel Nova** - Auto-discovery enabled with version detection
## Changes Included
- Core Laravel documentation updates for all supported versions
- External Laravel services documentation with auto-discovered sections
- Enhanced content validation and quality scoring
- Improved fallback mechanisms for manual configuration
Auto-discovery system will automatically detect new documentation pages and adapt to structural changes in Laravel service documentation sites.
branch: update-laravel-docs
- name: Enable auto-merge and wait for checks
if: steps.check-updates.outputs.updates_available == 'true' && steps.create-pr.outputs.pull-request-number
run: |
# Enable auto-merge
gh pr merge ${{ steps.create-pr.outputs.pull-request-number }} --auto --squash
# Check if there are any checks configured for this PR
echo "Checking for required status checks..."
CHECK_COUNT=$(gh pr checks ${{ steps.create-pr.outputs.pull-request-number }} --json state | jq '. | length')
if [ "$CHECK_COUNT" -gt 0 ]; then
echo "Found $CHECK_COUNT checks. Waiting for all checks to complete..."
gh pr checks ${{ steps.create-pr.outputs.pull-request-number }} --watch
else
echo "No checks found. Auto-merge will proceed without waiting for checks."
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
auto-tag-after-merge:
runs-on: ubuntu-latest
needs: [check-update]
if: needs.check-update.outputs.updates_available == 'true'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Wait for PR to be merged
id: wait-for-merge
run: |
PR_NUMBER="${{ needs.check-update.outputs.pr_number }}"
if [ -z "$PR_NUMBER" ]; then
echo "No PR number available"
exit 1
fi
# Wait up to 10 minutes for the PR to be merged
for i in {1..80}; do
PR_STATE=$(gh pr view $PR_NUMBER --json state,mergedAt -q '.state')
if [ "$PR_STATE" = "MERGED" ]; then
echo "PR $PR_NUMBER has been merged!"
# Get the merge commit SHA
MERGE_COMMIT=$(gh pr view $PR_NUMBER --json mergeCommit -q '.mergeCommit.oid')
echo "merge_commit=$MERGE_COMMIT" >> $GITHUB_OUTPUT
exit 0
fi
echo "PR state: $PR_STATE. Waiting... (attempt $i/80)"
sleep 15
done
echo "PR was not merged within timeout"
exit 1
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout merge commit
run: |
git fetch origin
git checkout ${{ steps.wait-for-merge.outputs.merge_commit }}
- name: Create new patch version tag and release
run: |
# Get the latest tag, default to v0.0.0 if no tags exist
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
echo "Latest tag: $LATEST_TAG"
# Extract version numbers
VERSION=${LATEST_TAG#v}
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
# Increment patch version for docs updates
NEW_PATCH=$((PATCH + 1))
NEW_VERSION="v${MAJOR}.${MINOR}.${NEW_PATCH}"
echo "Creating new tag: $NEW_VERSION"
git tag $NEW_VERSION
git push origin $NEW_VERSION
echo "Creating GitHub release: $NEW_VERSION"
# Create GitHub release
gh release create $NEW_VERSION \
--title "$NEW_VERSION" \
--notes "Documentation Update - Updated Laravel and external services documentation to latest version" \
--latest
env:
GH_TOKEN: ${{ secrets.PAT_FOR_WORKFLOWS }}