Skip to content

Commit 30603ec

Browse files
committed
Added workflow and docs
1 parent f893460 commit 30603ec

File tree

2 files changed

+182
-0
lines changed

2 files changed

+182
-0
lines changed
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
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/friendliai/friendli-python'
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 || github.server_url }}/${{ github.repository }}
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+
# Create docs/architecture directory and copy CodeBoarding files
97+
- name: Copy CodeBoarding documentation to architecture folder
98+
if: steps.git-changes.outputs.has_git_changes == 'true' && steps.codeboarding.outputs.has_changes == 'true'
99+
run: |
100+
# Create docs/architecture directory if it doesn't exist
101+
mkdir -p docs/architecture
102+
103+
# Create on_boarding.md if it doesn't exist
104+
if [ ! -f "docs/architecture/on_boarding.md" ]; then
105+
cat > docs/architecture/on_boarding.md << 'EOF'
106+
# Friendli Python SDK - Architecture & Onboarding
107+
108+
This section contains automatically generated documentation to help developers understand the codebase architecture and onboarding process.
109+
110+
## Generated Documentation
111+
112+
The following documentation files are automatically generated by CodeBoarding to provide insights into the codebase:
113+
114+
EOF
115+
fi
116+
117+
# Log the files found in the CodeBoarding directory
118+
echo "📁 Scanning CodeBoarding directory for .md files..."
119+
ls -la .codeboarding/ || echo "⚠️ CodeBoarding directory not found"
120+
121+
# Copy all .md files from CodeBoarding to docs/architecture
122+
copied_files_count=0
123+
124+
for file in .codeboarding/*.md; do
125+
if [ -f "$file" ]; then
126+
filename=$(basename "$file")
127+
echo "✅ Copying: $filename to docs/architecture/"
128+
cp "$file" "docs/architecture/$filename"
129+
copied_files_count=$((copied_files_count + 1))
130+
131+
# Add reference to on_boarding.md
132+
echo "- [$filename](./$filename)" >> docs/architecture/on_boarding.md
133+
fi
134+
done
135+
136+
# Add timestamp to on_boarding.md
137+
echo "" >> docs/architecture/on_boarding.md
138+
echo "_Last updated: $(date -u '+%Y-%m-%d %H:%M:%S UTC')_" >> docs/architecture/on_boarding.md
139+
140+
# Summary logging
141+
echo ""
142+
echo "📊 File copy summary:"
143+
echo " - Total .md files copied: $copied_files_count"
144+
echo " - Destination: docs/architecture/"
145+
146+
# List final contents
147+
if [ $copied_files_count -gt 0 ]; then
148+
echo " - Files in destination:"
149+
ls -la docs/architecture/*.md 2>/dev/null || echo " No .md files found in destination"
150+
fi
151+
152+
echo "CodeBoarding documentation copied to docs/architecture/"
153+
154+
- name: Commit and push changes
155+
if: steps.git-changes.outputs.has_git_changes == 'true' && steps.codeboarding.outputs.has_changes == 'true'
156+
run: |
157+
git config --local user.email "action@github.com"
158+
git config --local user.name "GitHub Action"
159+
git add .
160+
git commit -m "docs: update codeboarding architecture documentation
161+
162+
## 📚 Architecture Documentation Update
163+
This commit contains updated documentation files fetched from the CodeBoarding service and copied to the architecture documentation section.
164+
165+
### 📊 Summary
166+
- Documentation files created/updated: ${{ steps.codeboarding.outputs.markdown_files_created }}
167+
- JSON files created/updated: ${{ steps.codeboarding.outputs.json_files_created }}
168+
- Documentation directory: ${{ steps.codeboarding.outputs.output_directory }}/
169+
- JSON directory: ${{ steps.codeboarding.outputs.json_directory }}/
170+
- Output format: ${{ github.event.inputs.output_format || '.md' }}
171+
- Repository analyzed: ${{ github.server_url }}/${{ github.repository }}
172+
- Destination: docs/architecture/
173+
174+
The generated .md files have been automatically copied to the architecture documentation section and referenced in on_boarding.md.
175+
176+
🤖 This commit was automatically generated by the CodeBoarding documentation update workflow."
177+
git push

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,18 @@ When using Friendli Python SDK, you need to provide a Friendli Token for authent
1717
5. Create a new Friendli Token by clicking the "Create token" button.
1818
6. Copy the token and save it in a safe place. You will not be able to see this token again once the page is refreshed.
1919

20+
## Architecture & Development Onboarding
21+
22+
For developers looking to understand the codebase architecture and get started with contributing to the Friendli Python SDK, please refer to our comprehensive [Architecture & Onboarding Guide](./docs/architecture/on_boarding.md). This documentation is automatically generated and maintained to provide up-to-date insights into the codebase structure, patterns, and development workflows.
23+
2024
<!-- No Summary [summary] -->
2125

2226
<!-- Start Table of Contents [toc] -->
2327
## Table of Contents
2428
<!-- $toc-max-depth=2 -->
2529
* [Friendli Python SDK](#friendli-python-sdk)
2630
* [Token Setup](#token-setup)
31+
* [Architecture & Development Onboarding](#architecture--development-onboarding)
2732
* [SDK Installation](#sdk-installation)
2833
* [SDK Example Usage](#sdk-example-usage)
2934
* [Authentication](#authentication)

0 commit comments

Comments
 (0)