|
| 1 | +name: CodeBoarding Documentation update workflow |
| 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/pipelex' |
| 12 | + type: string |
| 13 | + source_branch: |
| 14 | + description: 'Source branch for generation' |
| 15 | + required: false |
| 16 | + default: 'main' |
| 17 | + type: string |
| 18 | + target_branch: |
| 19 | + description: 'Target branch for pull request' |
| 20 | + required: false |
| 21 | + default: 'main' |
| 22 | + type: string |
| 23 | + output_format: |
| 24 | + description: 'Output format for documentation' |
| 25 | + required: false |
| 26 | + default: '.md' |
| 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-action-usage: |
| 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 # Required to access branch history |
| 51 | + |
| 52 | + # Determine branches based on context |
| 53 | + - name: Set branch variables |
| 54 | + id: set-branches |
| 55 | + run: | |
| 56 | + if [ "${{ github.event_name }}" = "pull_request" ]; then |
| 57 | + echo "source_branch=${{ github.head_ref }}" >> $GITHUB_OUTPUT |
| 58 | + echo "target_branch=${{ github.base_ref }}" >> $GITHUB_OUTPUT |
| 59 | + elif [ "${{ github.event.inputs.source_branch }}" != "" ] && [ "${{ github.event.inputs.target_branch }}" != "" ]; then |
| 60 | + echo "source_branch=${{ github.event.inputs.source_branch }}" >> $GITHUB_OUTPUT |
| 61 | + echo "target_branch=${{ github.event.inputs.target_branch }}" >> $GITHUB_OUTPUT |
| 62 | + else |
| 63 | + echo "source_branch=main" >> $GITHUB_OUTPUT |
| 64 | + echo "target_branch=main" >> $GITHUB_OUTPUT |
| 65 | + fi |
| 66 | +
|
| 67 | + - name: Fetch CodeBoarding Documentation |
| 68 | + timeout-minutes: 30 |
| 69 | + id: codeboarding |
| 70 | + uses: CodeBoarding/CodeBoarding-GHAction@0.1.2 |
| 71 | + with: |
| 72 | + repository_url: ${{ github.event.inputs.repository_url || 'https://github.com/Pipelex/pipelex' }} |
| 73 | + source_branch: ${{ steps.set-branches.outputs.source_branch }} |
| 74 | + target_branch: ${{ steps.set-branches.outputs.target_branch }} |
| 75 | + output_directory: ${{ github.event.inputs.output_directory || '.codeboarding' }} |
| 76 | + output_format: ${{ github.event.inputs.output_format || '.md' }} |
| 77 | + |
| 78 | + - name: Display Action Results |
| 79 | + run: | |
| 80 | + echo "Documentation files created: ${{ steps.codeboarding.outputs.markdown_files_created }}" |
| 81 | + echo "JSON files created: ${{ steps.codeboarding.outputs.json_files_created }}" |
| 82 | + echo "Documentation directory: ${{ steps.codeboarding.outputs.output_directory }}" |
| 83 | + echo "JSON directory: ${{ steps.codeboarding.outputs.json_directory }}" |
| 84 | + echo "Has changes: ${{ steps.codeboarding.outputs.has_changes }}" |
| 85 | +
|
| 86 | + # Check if we have any changes to commit |
| 87 | + - name: Check for changes |
| 88 | + id: git-changes |
| 89 | + run: | |
| 90 | + if [ -n "$(git status --porcelain)" ]; then |
| 91 | + echo "has_git_changes=true" >> $GITHUB_OUTPUT |
| 92 | + else |
| 93 | + echo "has_git_changes=false" >> $GITHUB_OUTPUT |
| 94 | + fi |
| 95 | +
|
| 96 | + # Copy CodeBoarding files to docs/pages/advanced-customization |
| 97 | + - name: Copy CodeBoarding documentation to advanced-customization |
| 98 | + if: steps.git-changes.outputs.has_git_changes == 'true' && steps.codeboarding.outputs.has_changes == 'true' |
| 99 | + run: | |
| 100 | + # Create docs/pages/advanced-customization directory if it doesn't exist |
| 101 | + mkdir -p docs/pages/advanced-customization |
| 102 | + |
| 103 | + # Log the files found in the CodeBoarding directory |
| 104 | + echo "📁 Scanning CodeBoarding directory for .md files..." |
| 105 | + ls -la .codeboarding/ || echo "⚠️ CodeBoarding directory not found" |
| 106 | + |
| 107 | + # Copy all .md files from CodeBoarding to advanced-customization |
| 108 | + copied_files_count=0 |
| 109 | + |
| 110 | + for file in .codeboarding/*.md; do |
| 111 | + if [ -f "$file" ]; then |
| 112 | + filename=$(basename "$file") |
| 113 | + echo "✅ Copying: $filename to docs/pages/advanced-customization/" |
| 114 | + cp "$file" "docs/pages/advanced-customization/$filename" |
| 115 | + copied_files_count=$((copied_files_count + 1)) |
| 116 | + fi |
| 117 | + done |
| 118 | + |
| 119 | + # Summary logging |
| 120 | + echo "" |
| 121 | + echo "📊 File copy summary:" |
| 122 | + echo " - Total .md files copied: $copied_files_count" |
| 123 | + echo " - Destination: docs/pages/advanced-customization/" |
| 124 | + |
| 125 | + # List final contents |
| 126 | + if [ $copied_files_count -gt 0 ]; then |
| 127 | + echo " - Files in destination:" |
| 128 | + ls -la docs/pages/advanced-customization/*.md 2>/dev/null || echo " No .md files found in destination" |
| 129 | + fi |
| 130 | + |
| 131 | + echo "CodeBoarding documentation copied to docs/pages/advanced-customization/" |
| 132 | +
|
| 133 | + - name: Commit and push changes |
| 134 | + if: steps.git-changes.outputs.has_git_changes == 'true' && steps.codeboarding.outputs.has_changes == 'true' |
| 135 | + run: | |
| 136 | + git config --local user.email "action@github.com" |
| 137 | + git config --local user.name "GitHub Action" |
| 138 | + git add . |
| 139 | + git commit -m "docs: update codeboarding documentation in advanced-customization |
| 140 | +
|
| 141 | + ## 📚 Documentation Update |
| 142 | + This commit contains updated documentation files fetched from the CodeBoarding service and copied to the advanced-customization section. |
| 143 | + |
| 144 | + ### 📊 Summary |
| 145 | + - Documentation files created/updated: ${{ steps.codeboarding.outputs.markdown_files_created }} |
| 146 | + - JSON files created/updated: ${{ steps.codeboarding.outputs.json_files_created }} |
| 147 | + - Documentation directory: ${{ steps.codeboarding.outputs.output_directory }}/ |
| 148 | + - JSON directory: ${{ steps.codeboarding.outputs.json_directory }}/ |
| 149 | + - Output format: ${{ github.event.inputs.output_format || '.md' }} |
| 150 | + - Repository analyzed: ${{ steps.codeboarding.outputs.repo_url }} |
| 151 | + - Destination: docs/pages/advanced-customization/ |
| 152 | + |
| 153 | + The generated .md files have been automatically copied to the advanced-customization documentation section. |
| 154 | + |
| 155 | + 🤖 This commit was automatically generated by the CodeBoarding documentation update workflow." |
| 156 | + git push |
0 commit comments