@@ -3,11 +3,34 @@ name: Example Usage of CodeBoarding Action
33on :
44 workflow_dispatch :
55 inputs :
6- test_repo :
6+ repository_url :
77 description : ' Repository URL to test with'
88 required : false
9- default : ' https://github.com/CodeBoarding/insights-core '
9+ default : ' https://github.com/microsoft/markitdown '
1010 type : string
11+ source_branch :
12+ description : ' Source branch for comparison'
13+ required : false
14+ default : ' main'
15+ type : string
16+ target_branch :
17+ description : ' Target branch for comparison'
18+ required : false
19+ default : ' develop'
20+ type : string
21+ output_format :
22+ description : ' Output format for documentation'
23+ required : false
24+ default : ' .md'
25+ type : choice
26+ options :
27+ - ' .md'
28+ - ' .rst'
29+
30+ pull_request :
31+ branches : [ main, master ]
32+ types : [opened, synchronize, reopened]
33+
1134 schedule :
1235 # Run daily at 2 AM UTC
1336 - cron : ' 0 2 * * *'
@@ -24,22 +47,54 @@ jobs:
2447 uses : actions/checkout@v4
2548 with :
2649 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+ # Default to current branch and main
64+ echo "source_branch=${{ github.ref_name }}" >> $GITHUB_OUTPUT
65+ echo "target_branch=main" >> $GITHUB_OUTPUT
66+ fi
2767
2868 - name : Fetch CodeBoarding Documentation
2969 id : codeboarding
30- uses : ./ # Use the local action (when this is published, users would use: owner/repo@version)
70+ uses : ./
3171 with :
32- repository_url : ${{ github.repository }}
33- output_directory : ' .codeboarding'
72+ repository_url : ${{ github.event.inputs.repository_url }}
73+ source_branch : ${{ steps.set-branches.outputs.source_branch }}
74+ target_branch : ${{ steps.set-branches.outputs.target_branch }}
75+ output_directory : ' docs'
76+ output_format : ${{ github.event.inputs.output_format || '.md' }}
3477
3578 - name : Display Action Results
3679 run : |
37- echo "Files created: ${{ steps.codeboarding.outputs.files_created }}"
38- echo "Output directory: ${{ steps.codeboarding.outputs.output_directory }}"
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 }}"
3984 echo "Has changes: ${{ steps.codeboarding.outputs.has_changes }}"
4085
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+
4196 - name : Create Pull Request
42- if : steps.git-changes.outputs.has_git_changes == 'true'
97+ if : steps.git-changes.outputs.has_git_changes == 'true' && steps.codeboarding.outputs.has_changes == 'true'
4398 uses : peter-evans/create-pull-request@v5
4499 with :
45100 token : ${{ secrets.GITHUB_TOKEN }}
@@ -51,17 +106,21 @@ jobs:
51106 This PR contains updated documentation files fetched from the CodeBoarding service.
52107
53108 ### 📊 Summary
54- - **Files created/updated**: ${{ steps.codeboarding.outputs.files_created }}
55- - **Output directory**: `${{ steps.codeboarding.outputs.output_directory }}/`
56- - **Source endpoint**: ${{ vars.CODEBOARDING_ENDPOINT || 'codeboarding endpoint' }}
57- - **Repository analyzed**: ${{ github.event.inputs.test_repo || github.repository }}
109+ - **Documentation files created/updated**: ${{ steps.codeboarding.outputs.markdown_files_created }}
110+ - **JSON files created/updated**: ${{ steps.codeboarding.outputs.json_files_created }}
111+ - **Documentation directory**: `${{ steps.codeboarding.outputs.output_directory }}/`
112+ - **JSON directory**: `${{ steps.codeboarding.outputs.json_directory }}/`
113+ - **Source branch**: `${{ steps.set-branches.outputs.source_branch }}`
114+ - **Target branch**: `${{ steps.set-branches.outputs.target_branch }}`
115+ - **Output format**: `${{ github.event.inputs.output_format || '.md' }}`
116+ - **Repository analyzed**: `${{ steps.codeboarding.outputs.repo_url }}`
58117
59118 ### 🔍 Changes
60- Files have been updated in the `${{ steps.codeboarding.outputs.output_directory }}/` directory with fresh documentation content .
119+ Files have been updated with fresh documentation content based on code changes between branches .
61120
62121 ---
63122
64123 🤖 This PR was automatically generated by the CodeBoarding documentation update workflow.
65124 branch : docs/codeboarding-update
66- base : main
125+ base : ${{ steps.set-branches.outputs.target_branch }}
67126 delete-branch : true
0 commit comments