SharePoint Static Site Deployment Setup Guide¶
This guide explains how to set up and use the SharePoint deployment workflow for the ABS Platform documentation.
Overview¶
The teams-sharepoint-deploy.yml workflow automatically compiles the documentation in the docs/ directory into a static site using MkDocs and deploys it to Microsoft SharePoint, making it accessible in Microsoft Teams.
Workflow Features¶
✅ Automatic builds - Triggers on push to main when docs change
✅ Manual deployment - Can be triggered via workflow_dispatch
✅ Validation - Checks for required secrets and build success
✅ Version management - Creates timestamped deployment folders
✅ Teams integration - Sends notifications with deployment links
✅ Error handling - Graceful failure handling with detailed logs
Prerequisites¶
⚠️ Important: SharePoint requires certificate-based authentication for app-only access. Client ID and secret authentication is not supported. See the Certificate Setup Guide for detailed instructions.
1. SharePoint Site Setup¶
You need a SharePoint site with: - A document library for hosting the documentation - Appropriate permissions for the service principal
2. Azure AD App Registration (Service Principal)¶
Create an Azure AD app registration:
- Go to Azure Portal → Azure Active Directory → App registrations
- Click "New registration"
- Name:
GitHub Actions - ABS Docs Deployment - Supported account types: Single tenant
- Click "Register"
After registration:
- Note the Application (client) ID → This is SHAREPOINT_APP_ID
- Note the Directory (tenant) ID → This is SHAREPOINT_TENANT_ID
3. Generate and Upload Certificate¶
Important: SharePoint requires certificate-based authentication. Follow the detailed guide: SharePoint Certificate Setup Guide
Quick Summary:
- Generate a certificate (PowerShell or OpenSSL)
- Upload the
.cerfile to Azure AD app registration - Convert the
.pfxfile to Base64 for GitHub secret
PowerShell Quick Command:
# Generate certificate
$cert = New-SelfSignedCertificate -Subject "CN=GitHubActions-ABSDocs" `
-CertStoreLocation "Cert:\CurrentUser\My" -KeyExportPolicy Exportable `
-NotAfter (Get-Date).AddYears(2)
# Export PFX and CER
$password = ConvertTo-SecureString -String "YourStrongPassword!" -Force -AsPlainText
Export-PfxCertificate -Cert $cert -FilePath "cert.pfx" -Password $password
Export-Certificate -Cert $cert -FilePath "cert.cer"
# Convert to Base64
[Convert]::ToBase64String([IO.File]::ReadAllBytes("cert.pfx")) | Out-File "cert-base64.txt"
Upload to Azure AD:
1. Go to your app registration → "Certificates & secrets"
2. Under "Certificates" tab, click "Upload certificate"
3. Select the cert.cer file
4. Click "Add"
4. Grant SharePoint Permissions¶
Grant the app permissions to access SharePoint:
- In your app registration, go to "API permissions"
- Click "Add a permission"
- Choose "SharePoint"
- Choose "Application permissions"
- Add these permissions:
Sites.ReadWrite.All(orSites.Selectedfor more security)- Click "Add permissions"
- Click "Grant admin consent" for your tenant
5. SharePoint Site Permissions¶
Grant the app access to your specific SharePoint site:
# Install PnP PowerShell if needed
Install-Module PnP.PowerShell -Scope CurrentUser
# Connect to your SharePoint site
Connect-PnPOnline -Url "https://yourtenant.sharepoint.com/sites/yoursite" -Interactive
# Grant the app permissions
Grant-PnPAzureADAppSitePermission `
-AppId "YOUR_APP_ID" `
-DisplayName "GitHub Actions - ABS Docs" `
-Permissions Write
GitHub Secrets Configuration¶
Configure the following secrets in your GitHub repository:
Navigation¶
Go to: Repository Settings → Secrets and variables → Actions → New repository secret
Required Secrets (Certificate Authentication)¶
| Secret Name | Description | Example |
|---|---|---|
SHAREPOINT_SITE_URL |
Your SharePoint site URL | https://yourtenant.sharepoint.com/sites/yoursite |
SHAREPOINT_DOCUMENT_LIBRARY |
Document library folder name | Documentation or Shared Documents/Documentation |
SHAREPOINT_APP_ID |
Azure AD App (client) ID | 12345678-1234-1234-1234-123456789abc |
SHAREPOINT_CERTIFICATE_BASE64 |
Base64-encoded PFX certificate | Contents of cert-base64.txt file |
SHAREPOINT_CERTIFICATE_PASSWORD |
PFX certificate password | The password you set when creating PFX |
SHAREPOINT_TENANT_ID |
Azure AD Directory (tenant) ID | 87654321-4321-4321-4321-cba987654321 |
Note:
SHAREPOINT_CERTIFICATE_BASE64should be the entire base64 string (no line breaks in the GitHub secret, though the file may have them)
Alternative: Username/Password Authentication (Not Recommended)¶
⚠️ Only use if you cannot use certificate authentication
| Secret Name | Description |
|---|---|
SHAREPOINT_USERNAME |
SharePoint admin username |
SHAREPOINT_PASSWORD |
SharePoint admin password |
SHAREPOINT_SITE_URL |
Your SharePoint site URL |
SHAREPOINT_DOCUMENT_LIBRARY |
Document library folder name |
Note: Still need SHAREPOINT_APP_ID and SHAREPOINT_TENANT_ID are NOT required for username/password auth.
Optional Secrets¶
| Secret Name | Description | Required |
|---|---|---|
TEAMS_WEBHOOK_URL |
Incoming webhook URL for Teams notifications | Optional |
Creating a Teams Webhook (Optional)¶
To receive deployment notifications in Teams:
- In Teams, go to the channel where you want notifications
- Click "..." → "Connectors" → "Incoming Webhook"
- Name:
Documentation Deployment - Upload an icon (optional)
- Click "Create"
- Copy the webhook URL
- Add it as
TEAMS_WEBHOOK_URLsecret in GitHub
Usage¶
Automatic Deployment¶
The workflow automatically triggers when:
- Changes are pushed to the main branch
- Changes are made to files in the docs/ directory
- The workflow file itself is modified
Manual Deployment¶
To manually trigger a deployment:
- Go to your repository on GitHub
- Click "Actions" tab
- Select "Deploy Docs to SharePoint for Teams"
- Click "Run workflow"
- Select branch (usually
main) - Click "Run workflow"
Workflow Steps¶
The workflow performs these steps:
- Checkout - Clones the repository with full history
- Setup Python - Installs Python 3.x with dependency caching
- Install Dependencies - Installs MkDocs and plugins from
docs/requirements.txt - Build Documentation - Compiles docs using MkDocs (Teams-optimized config if available)
- Validate Secrets - Checks all required secrets are configured
- Setup Node.js - Installs Node.js for SharePoint CLI
- Install SharePoint CLI - Installs Microsoft 365 CLI tools
- Authenticate - Logs into SharePoint using service principal
- Prepare Deployment - Creates deployment folder and copies files
- Deploy to SharePoint - Uploads all files to SharePoint document library
- Send Notification - Sends Teams notification (if configured)
Deployment Structure¶
Files are deployed to SharePoint in this structure:
Shared Documents/
└── [SHAREPOINT_DOCUMENT_LIBRARY]/
└── abs-platform-docs-[BUILD_NUMBER]/
├── index.html
├── deployment-info.json
├── teams-redirect.html
├── assets/
├── business/
├── architecture/
└── ...
Each deployment creates a new timestamped folder, allowing you to: - Keep multiple versions - Roll back if needed - See deployment history
Accessing the Documentation¶
After deployment, access your documentation at:
https://yourtenant.sharepoint.com/sites/yoursite/Shared Documents/[LIBRARY]/abs-platform-docs-[BUILD]/index.html
Adding to Teams Tab¶
- In Teams, go to your channel
- Click "+" to add a tab
- Choose "Website"
- Name:
ABS Platform Docs - URL: Your SharePoint documentation URL
- Click "Save"
Troubleshooting¶
Build Fails: "Module not found"¶
Solution: Ensure all required packages are in docs/requirements.txt
pip install -r docs/requirements.txt
mkdocs build --config-file docs/mkdocs.yml --strict
Authentication Fails¶
Possible causes: - App secret expired → Generate new secret - Missing permissions → Check API permissions in Azure AD - Site permissions not granted → Run Grant-PnPAzureADAppSitePermission
Files Not Uploading¶
Check: - Document library name is correct - Service principal has Write permissions - SharePoint site URL is correct (no trailing slash)
Teams Notification Not Sent¶
This is non-critical. Check:
- TEAMS_WEBHOOK_URL secret is set correctly
- Webhook hasn't been deleted in Teams
- Webhook URL is complete (should start with https://)
Monitoring¶
View Deployment Logs¶
- Go to "Actions" tab in GitHub
- Click on the workflow run
- Click on "build-and-deploy" job
- Expand each step to see detailed logs
Deployment Metadata¶
Each deployment includes a deployment-info.json file with:
- Deployment timestamp
- Git commit SHA
- Branch name
- Build number
- Who triggered the deployment
Best Practices¶
- Test locally first - Run
mkdocs buildlocally before pushing - Use draft PRs - Test documentation changes in pull requests
- Monitor builds - Check GitHub Actions for any warnings
- Regular secret rotation - Rotate app secrets periodically
- Backup important versions - Keep important deployment folders
Advanced Configuration¶
Using Teams-Optimized Config¶
The workflow checks for docs/mkdocs-teams.yml and uses it if available. This allows you to:
- Customize theme for Teams viewing
- Enable Teams-specific features
- Optimize for iframe display
Custom Deployment Folder¶
To change the document library location, update the SHAREPOINT_DOCUMENT_LIBRARY secret.
Multiple Environments¶
Create separate workflows for different environments:
- teams-sharepoint-deploy-staging.yml → Staging site
- teams-sharepoint-deploy-prod.yml → Production site
Each with different secrets for different SharePoint sites.
Security Considerations¶
- Service Principal - Use app permissions, not delegated user permissions
- Least Privilege - Grant minimum required SharePoint permissions
- Secret Rotation - Rotate client secrets regularly (every 6-12 months)
- Audit Logs - Monitor SharePoint audit logs for app activity
- Site Isolation - Use dedicated SharePoint site for documentation
Support¶
If you encounter issues:
- Check the GitHub Actions logs for detailed error messages
- Verify all secrets are configured correctly
- Test SharePoint CLI authentication locally:
npm install -g @pnp/cli-microsoft365 m365 login --authType servicePrincipal --appId YOUR_APP_ID --appSecret YOUR_SECRET --tenant YOUR_TENANT - Review Azure AD app permissions and SharePoint site permissions
Related Documentation¶
mkdocs.ymlat the repo root is the canonical MkDocs configuration file.- Repository Management
- Documentation Policy
Last Updated: 2025-10-08
Workflow Version: 2.0 (Corrected and Enhanced)