|
| 1 | +name: CodeBoarding Documentation Update |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: '0 20 * * 6' # Every Saturday at 8:00 PM UTC |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + repository_url: |
| 9 | + description: 'Repository URL to test with' |
| 10 | + required: false |
| 11 | + default: 'https://github.com/CodeBoarding/ChatterBot' |
| 12 | + type: string |
| 13 | + source_branch: |
| 14 | + description: 'Source branch for generation' |
| 15 | + required: false |
| 16 | + default: 'master' |
| 17 | + type: string |
| 18 | + target_branch: |
| 19 | + description: 'Target branch for pull request' |
| 20 | + required: false |
| 21 | + default: 'master' |
| 22 | + type: string |
| 23 | + output_format: |
| 24 | + description: 'Output format for documentation' |
| 25 | + required: false |
| 26 | + default: '.rst' |
| 27 | + type: choice |
| 28 | + options: |
| 29 | + - '.mdx' |
| 30 | + - '.md' |
| 31 | + - '.rst' |
| 32 | + output_directory: |
| 33 | + description: 'Output directory for documentation files' |
| 34 | + required: false |
| 35 | + default: '.codeboarding' |
| 36 | + type: string |
| 37 | + |
| 38 | +jobs: |
| 39 | + update-docs: |
| 40 | + runs-on: ubuntu-latest |
| 41 | + timeout-minutes: 45 |
| 42 | + permissions: |
| 43 | + contents: write |
| 44 | + pull-requests: write |
| 45 | + steps: |
| 46 | + - name: Checkout repository |
| 47 | + uses: actions/checkout@v4 |
| 48 | + with: |
| 49 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 50 | + fetch-depth: 0 |
| 51 | + |
| 52 | + - name: Set branch variables |
| 53 | + id: set-branches |
| 54 | + run: | |
| 55 | + if [ "${{ github.event_name }}" = "pull_request" ]; then |
| 56 | + echo "source_branch=${{ github.head_ref }}" >> $GITHUB_OUTPUT |
| 57 | + echo "target_branch=${{ github.base_ref }}" >> $GITHUB_OUTPUT |
| 58 | + elif [ "${{ github.event.inputs.source_branch }}" != "" ] && [ "${{ github.event.inputs.target_branch }}" != "" ]; then |
| 59 | + echo "source_branch=${{ github.event.inputs.source_branch }}" >> $GITHUB_OUTPUT |
| 60 | + echo "target_branch=${{ github.event.inputs.target_branch }}" >> $GITHUB_OUTPUT |
| 61 | + else |
| 62 | + echo "source_branch=master" >> $GITHUB_OUTPUT |
| 63 | + echo "target_branch=master" >> $GITHUB_OUTPUT |
| 64 | + fi |
| 65 | +
|
| 66 | + - name: Fetch CodeBoarding Documentation |
| 67 | + timeout-minutes: 30 |
| 68 | + id: codeboarding |
| 69 | + uses: CodeBoarding/CodeBoarding-GHAction@0.1.2 |
| 70 | + with: |
| 71 | + repository_url: ${{ github.event.inputs.repository_url || 'https://github.com/CodeBoarding/ChatterBot' }} |
| 72 | + source_branch: ${{ steps.set-branches.outputs.source_branch }} |
| 73 | + target_branch: ${{ steps.set-branches.outputs.target_branch }} |
| 74 | + output_directory: ${{ github.event.inputs.output_directory || '.codeboarding' }} |
| 75 | + output_format: ${{ github.event.inputs.output_format || '.rst' }} |
| 76 | + |
| 77 | + - name: Display Action Results |
| 78 | + run: | |
| 79 | + echo "Documentation files created: ${{ steps.codeboarding.outputs.markdown_files_created }}" |
| 80 | + echo "JSON files created: ${{ steps.codeboarding.outputs.json_files_created }}" |
| 81 | + echo "Documentation directory: ${{ steps.codeboarding.outputs.output_directory }}" |
| 82 | + echo "JSON directory: ${{ steps.codeboarding.outputs.json_directory }}" |
| 83 | + echo "Has changes: ${{ steps.codeboarding.outputs.has_changes }}" |
| 84 | +
|
| 85 | + - name: Check for changes |
| 86 | + id: git-changes |
| 87 | + run: | |
| 88 | + if [ -n "$(git status --porcelain)" ]; then |
| 89 | + echo "has_git_changes=true" >> $GITHUB_OUTPUT |
| 90 | + else |
| 91 | + echo "has_git_changes=false" >> $GITHUB_OUTPUT |
| 92 | + fi |
| 93 | +
|
| 94 | + - name: Copy CodeBoarding documentation to architecture |
| 95 | + if: steps.git-changes.outputs.has_git_changes == 'true' && steps.codeboarding.outputs.has_changes == 'true' |
| 96 | + run: | |
| 97 | + mkdir -p docs/architecture |
| 98 | + |
| 99 | + echo "📁 Scanning CodeBoarding directory for .rst files..." |
| 100 | + ls -la .codeboarding/ || echo "⚠️ CodeBoarding directory not found" |
| 101 | + |
| 102 | + copied_files_count=0 |
| 103 | + |
| 104 | + for file in .codeboarding/*.rst; do |
| 105 | + if [ -f "$file" ]; then |
| 106 | + filename=$(basename "$file") |
| 107 | + echo "✅ Copying: $filename to docs/architecture/" |
| 108 | + cp "$file" "docs/architecture/$filename" |
| 109 | + copied_files_count=$((copied_files_count + 1)) |
| 110 | + fi |
| 111 | + done |
| 112 | + |
| 113 | + echo "" |
| 114 | + echo "📊 File copy summary:" |
| 115 | + echo " - Total .rst files copied: $copied_files_count" |
| 116 | + echo " - Destination: docs/architecture/" |
| 117 | + |
| 118 | + if [ $copied_files_count -gt 0 ]; then |
| 119 | + echo " - Files in destination:" |
| 120 | + ls -la docs/architecture/*.rst 2>/dev/null || echo " No .rst files found in destination" |
| 121 | + fi |
| 122 | + |
| 123 | + echo "CodeBoarding documentation copied to docs/architecture/" |
| 124 | +
|
| 125 | + - name: Commit and push changes |
| 126 | + if: steps.git-changes.outputs.has_git_changes == 'true' && steps.codeboarding.outputs.has_changes == 'true' |
| 127 | + run: | |
| 128 | + git config --local user.email "action@github.com" |
| 129 | + git config --local user.name "GitHub Action" |
| 130 | + git add . |
| 131 | + git commit -m "docs: update codeboarding architecture documentation |
| 132 | +
|
| 133 | + ## 📚 Documentation Update |
| 134 | + This commit contains updated documentation files fetched from the CodeBoarding service. |
| 135 | + |
| 136 | + ### 📊 Summary |
| 137 | + - Documentation files created/updated: ${{ steps.codeboarding.outputs.markdown_files_created }} |
| 138 | + - JSON files created/updated: ${{ steps.codeboarding.outputs.json_files_created }} |
| 139 | + - Documentation directory: ${{ steps.codeboarding.outputs.output_directory }}/ |
| 140 | + - JSON directory: ${{ steps.codeboarding.outputs.json_directory }}/ |
| 141 | + - Output format: ${{ github.event.inputs.output_format || '.rst' }} |
| 142 | + - Repository analyzed: ${{ steps.codeboarding.outputs.repo_url }} |
| 143 | + - Destination: docs/architecture/ |
| 144 | + |
| 145 | + 🤖 This commit was automatically generated by the CodeBoarding documentation update workflow." |
| 146 | + git push |
0 commit comments