-
Notifications
You must be signed in to change notification settings - Fork 14
Generate and push HTML documentation #236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: sam <[email protected]>
Co-authored-by: sam <[email protected]>
| runs-on: macos-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Swift | ||
| uses: swift-actions/setup-swift@v1 | ||
| with: | ||
| swift-version: '5.9' | ||
|
|
||
| - name: Cache Swift packages | ||
| uses: actions/cache@v3 | ||
| with: | ||
| path: .build | ||
| key: ${{ runner.os }}-swift-${{ hashFiles('**/Package.resolved') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-swift- | ||
|
|
||
| - name: Build package | ||
| run: swift build | ||
|
|
||
| - name: Generate documentation | ||
| run: | | ||
| # Generate documentation for the Clerk target | ||
| swift package generate-documentation \ | ||
| --target Clerk \ | ||
| --disable-indexing \ | ||
| --transform-for-static-hosting \ | ||
| --hosting-base-path Clerk \ | ||
| --output-path ./docs | ||
|
|
||
| - name: Setup docs directory structure | ||
| run: | | ||
| # Create a clean docs directory structure | ||
| mkdir -p ./docs-output | ||
|
|
||
| # Copy the generated documentation | ||
| if [ -d "./docs" ]; then | ||
| cp -r ./docs/* ./docs-output/ | ||
| fi | ||
|
|
||
| # Create index.html if it doesn't exist | ||
| if [ ! -f "./docs-output/index.html" ]; then | ||
| cat > ./docs-output/index.html << 'EOF' | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <title>Clerk Documentation</title> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <style> | ||
| body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; margin: 40px; } | ||
| .header { text-align: center; margin-bottom: 40px; } | ||
| .links { display: flex; justify-content: center; gap: 20px; flex-wrap: wrap; } | ||
| .link { padding: 10px 20px; background: #007AFF; color: white; text-decoration: none; border-radius: 8px; } | ||
| .link:hover { background: #0056CC; } | ||
| </style> | ||
| </head> | ||
| <body> | ||
| <div class="header"> | ||
| <h1>Clerk Documentation</h1> | ||
| <p>Swift Package Documentation</p> | ||
| </div> | ||
| <div class="links"> | ||
| <a href="./documentation/clerk/" class="link">Browse Documentation</a> | ||
| </div> | ||
| </body> | ||
| </html> | ||
| EOF | ||
| fi | ||
|
|
||
| - name: Deploy to docs branch | ||
| run: | | ||
| # Configure git | ||
| git config --global user.name 'github-actions[bot]' | ||
| git config --global user.email 'github-actions[bot]@users.noreply.github.com' | ||
|
|
||
| # Create/checkout docs branch | ||
| git checkout --orphan docs || git checkout docs | ||
|
|
||
| # Remove all files except docs-output | ||
| git rm -rf . 2>/dev/null || true | ||
|
|
||
| # Copy documentation files to root | ||
| cp -r ./docs-output/* . 2>/dev/null || true | ||
|
|
||
| # Add and commit all documentation files | ||
| git add . | ||
|
|
||
| # Check if there are changes to commit | ||
| if git diff --staged --quiet; then | ||
| echo "No changes to commit" | ||
| exit 0 | ||
| fi | ||
|
|
||
| git commit -m "📚 Update documentation ($(date '+%Y-%m-%d %H:%M:%S'))" | ||
|
|
||
| # Push to docs branch | ||
| git push origin docs --force |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 4 months ago
To fix the issue, we will add a permissions block at the root of the workflow file. This block will explicitly define the minimal permissions required for the workflow to function. Based on the workflow's actions, it needs contents: write to push changes to the docs branch and contents: read to access the repository's files. These permissions will be applied to all jobs in the workflow.
-
Copy modified lines R3-R5
| @@ -2,2 +2,5 @@ | ||
|
|
||
| permissions: | ||
| contents: write | ||
|
|
||
| on: |
Add a GitHub Action to automatically generate Swift-DocC HTML documentation and push it to a dedicated
docsbranch.Slack Thread