Added workflow for updating documentation

This commit is contained in:
ivanmilevtues 2025-06-24 00:54:24 +02:00
parent 4ac3f07510
commit 57077d9db0

110
.github/workflows/update-docs.yml vendored Normal file
View File

@ -0,0 +1,110 @@
name: Update Documentation
on:
workflow_dispatch:
inputs:
repository_url:
description: 'Repository URL to test with'
required: false
default: 'https://github.com/${{ github.repository }}'
type: string
source_branch:
description: 'Source branch for comparison'
required: false
default: 'master'
type: string
target_branch:
description: 'Target branch for comparison'
required: false
default: 'master'
type: string
output_format:
description: 'Output format for documentation'
required: false
default: '.md'
type: choice
options:
- '.md'
- '.rst'
schedule:
# Runs every Monday at 09:00 UTC
- cron: '0 9 * * 1'
jobs:
update-docs-action-usage:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0 # Required to access branch history
# Determine branches based on context
- name: Set branch variables
id: set-branches
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "source_branch=${{ github.head_ref }}" >> $GITHUB_OUTPUT
echo "target_branch=${{ github.base_ref }}" >> $GITHUB_OUTPUT
elif [ "${{ github.event.inputs.source_branch }}" != "" ] && [ "${{ github.event.inputs.target_branch }}" != "" ]; then
echo "source_branch=${{ github.event.inputs.source_branch }}" >> $GITHUB_OUTPUT
echo "target_branch=${{ github.event.inputs.target_branch }}" >> $GITHUB_OUTPUT
else
echo "source_branch=master" >> $GITHUB_OUTPUT
echo "target_branch=master" >> $GITHUB_OUTPUT
fi
- name: Fetch CodeBoarding Documentation
id: codeboarding
uses: ./
with:
repository_url: ${{ github.event.inputs.repository_url }}
source_branch: ${{ steps.set-branches.outputs.source_branch }}
target_branch: ${{ steps.set-branches.outputs.target_branch }}
output_directory: '.codeboarding'
output_format: ${{ github.event.inputs.output_format || '.md' }}
- name: Display Action Results
run: |
echo "Documentation files created: ${{ steps.codeboarding.outputs.markdown_files_created }}"
echo "JSON files created: ${{ steps.codeboarding.outputs.json_files_created }}"
echo "Documentation directory: ${{ steps.codeboarding.outputs.output_directory }}"
echo "JSON directory: ${{ steps.codeboarding.outputs.json_directory }}"
echo "Has changes: ${{ steps.codeboarding.outputs.has_changes }}"
# Check if we have any changes to commit
- name: Check for changes
id: git-changes
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "has_git_changes=true" >> $GITHUB_OUTPUT
else
echo "has_git_changes=false" >> $GITHUB_OUTPUT
fi
- name: Create Pull Request
if: steps.git-changes.outputs.has_git_changes == 'true' && steps.codeboarding.outputs.has_changes == 'true'
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "docs: update codeboarding documentation"
title: "📚 CodeBoarding Documentation Update"
body: |
## 📚 Documentation Update
This PR contains updated documentation files fetched from the CodeBoarding service.
### 📊 Summary
- **Documentation files created/updated**: ${{ steps.codeboarding.outputs.markdown_files_created }}
- **JSON files created/updated**: ${{ steps.codeboarding.outputs.json_files_created }}
- **Documentation directory**: `${{ steps.codeboarding.outputs.output_directory }}/`
- **JSON directory**: `${{ steps.codeboarding.outputs.json_directory }}/`
- **Output format**: `${{ github.event.inputs.output_format || '.md' }}`
- **Repository analyzed**: `${{ steps.codeboarding.outputs.repo_url }}`
🤖 This PR was automatically generated by the CodeBoarding documentation update workflow.
branch: docs/codeboarding-update
base: master
delete-branch: true