GitLab Setup for Bluefly Documentation¶
This guide explains how to set up the Bluefly documentation system in GitLab, including the central documentation repository (BFDOCS) and the integration with individual project repositories.
Prerequisites¶
Before setting up the documentation system, ensure you have:
- Administrator access to the GitLab organization
- Access to all Bluefly project repositories
- Basic understanding of GitLab CI/CD
- Python 3.7+ installed locally
- Node.js 18+ installed locally
Repository Setup¶
Creating the BFDOCS Repository¶
- Log in to GitLab and navigate to your organization
- Click "New project" → "Create blank project"
- Enter the following information:
- Project name:
bfdocs
- Visibility level: Internal
- Initialize repository with a README
- Click "Create project"
Initial Configuration¶
Clone the repository locally and set up the basic structure:
git clone https://gitlab.com/bluefly/bfdocs.git
cd bfdocs
# Create standard directories
mkdir -p docs/architecture docs/guides docs/integration docs/ml docs/api docs/setup docs/projects
mkdir -p assets/images assets/stylesheets
mkdir -p scripts templates
Adding MkDocs Configuration¶
- Copy the
mkdocs.yml
file from this repository to your local clone - Install MkDocs locally to test the configuration:
pip install mkdocs mkdocs-material mkdocs serve
- Visit http://localhost:8000 to verify the site is working
Setting Up GitLab Pages¶
- Copy the
.gitlab-ci.yml
file from this repository to your local clone - Commit and push the changes:
git add . git commit -m "Initial documentation setup" git push
- Navigate to your GitLab project → Settings → Pages to verify the site is deployed
CI/CD Configuration¶
Setting Up CI/CD Variables¶
- Navigate to your GitLab project → Settings → CI/CD → Variables
- Add the following variables:
MKDOCS_MATERIAL_VERSION
:9.4.6
PYTHON_VERSION
:3.10
Creating Access Tokens¶
To allow project repositories to update the central documentation, create an access token:
- Navigate to your GitLab project → Settings → Access Tokens
- Create a new token with the following settings:
- Token name:
docs-sync-token
- Expiration date: Set an appropriate expiration (e.g., 1 year)
- Scopes:
api
,read_repository
,write_repository
- Copy the generated token for later use
Integrating with Project Repositories¶
Adding Documentation CI/CD to Projects¶
For each project that should participate in the documentation system:
- Navigate to the project repository
- Create a
.gitlab-ci.yml
file if it doesn't exist - Add the following include statement at the top:
include: - project: 'bluefly/bfdocs' file: 'ci/documentation.yml'
- Add the documentation token as a CI/CD variable:
- Navigate to the project's Settings → CI/CD → Variables
- Add a variable named
DOCS_TRIGGER_TOKEN
with the value of the token created earlier - Set it to "Protected" and not "Masked"
Initial Documentation Sync¶
To perform an initial sync of project documentation:
- Clone the project repository
- Run the sync script manually:
python /path/to/BFDOCS/scripts/sync_project_docs.py --project $(basename $(pwd)) --direction to_central --bfdocs /path/to/BFDOCS
- Commit and push the changes to BFDOCS
Verification¶
Once the setup is complete, verify that the documentation system is working:
- Make a change to a project's documentation
- Commit and push with a message containing "docs:"
- Check that the CI/CD pipeline runs successfully
- Verify that the change appears in the central documentation site
Configuring GitLab Webhooks (Optional)¶
For more immediate updates, set up webhooks:
- Navigate to the project repository → Settings → Webhooks
- Add a new webhook with:
- URL:
https://gitlab.com/api/v4/projects/<BFDOCS-PROJECT-ID>/trigger/pipeline
- Secret token: The docs-sync-token created earlier
- Trigger: Push events, Comments, Merge requests
- Branch filter: main
- Click "Add webhook"
Customizing the Documentation Site¶
Updating Theme Colors¶
-
Edit the
mkdocs.yml
file and modify the theme section:theme: name: material palette: primary: indigo # Change to your brand color accent: indigo
-
Edit the
assets/stylesheets/extra.css
file to add custom styles - Commit and push the changes
Adding Custom Logo and Favicon¶
- Place your logo in
assets/images/
- Update the
mkdocs.yml
file:theme: name: material logo: assets/images/your-logo.png favicon: assets/images/favicon.ico
- Commit and push the changes
Advanced Configuration¶
Multiple Documentation Versions¶
To support multiple versions of documentation:
-
Install the mike plugin:
pip install mike
-
Add mike configuration to
mkdocs.yml
:extra: version: provider: mike
-
Update the CI/CD pipeline to deploy versioned documentation with mike
Automated Testing¶
To add automated testing of documentation:
-
Add link checking to the CI/CD pipeline:
test-links: stage: test script: - pip install mkdocs-linkcheck - mkdocs linkcheck
-
Add spelling checking:
test-spelling: stage: test script: - pip install pyspelling - pyspelling -c .spellcheck.yml
Troubleshooting¶
Common Issues¶
Documentation Not Syncing¶
- Check the CI/CD pipeline logs for errors
- Verify that the documentation token is correctly set up
- Ensure the include statement in the project's
.gitlab-ci.yml
is correct - Check that the commit message contains the required trigger keyword
GitLab Pages Not Updating¶
- Check the Pages settings in the GitLab project
- Verify that the
pages
job in the CI/CD pipeline completed successfully - Clear your browser cache or try a different browser
Build Errors¶
- Check for syntax errors in the MkDocs configuration
- Verify that all required plugins are installed
- Check for broken links or references in the documentation
Maintenance¶
Regular Tasks¶
- Rotate the documentation access token annually
- Review and update the documentation structure as needed
- Clean up obsolete documentation
- Update dependencies (MkDocs, theme, plugins)
Monitoring¶
Set up monitoring for the documentation site:
- Add uptime monitoring to check the GitLab Pages site
- Set up alerts for documentation build failures
- Regularly check for broken links and outdated content
Conclusion¶
You now have a fully configured documentation system that aggregates documentation from all your Bluefly projects into a central, easily navigable site. This system automatically keeps documentation in sync and publishes changes when they occur.
For help or further customization, contact the Bluefly documentation team or open an issue in the BFDOCS repository.