-
Notifications
You must be signed in to change notification settings - Fork 0
Add Azure Static Web Apps deployment with Bicep IaC and automated CI/CD #11
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
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
25946d3
Initial plan
Copilot 074a0d5
Add Azure Static Web Apps deployment infrastructure and workflow
Copilot b252de7
Add deployment quickstart guide and automated deployment script
Copilot c7b7b2e
Remove build artifact and update gitignore for Bicep outputs
Copilot 27562d5
Update staticwebapp.config.json
robpitcher 28e6682
Update staticwebapp.config.json
robpitcher 06d43ef
logo
robpitcher 1288cc4
Update introduction.md to enhance warning about adventure racing inte…
6f2e655
Update race-formats.md to add headings for race categories and improv…
f10c715
logo
2fd793b
Remove unused logo path from global metadata in docfx.json
d62f349
Update devcontainer.json to include Azure CLI and Bicep installation
7ccd5cc
Update environment tag in bicep.parameters.json from Production to Dev
ca604b1
Remove deployment token output from main.bicep
22e8af7
Update README.md to enhance deployment options for GitHub Pages and A…
9172a64
Refactor README.md for clarity and enhance deployment instructions fo…
e8c6863
Update README.md to clarify GitHub Pages deployment instructions and …
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| # name: Deploy to Azure Static Web Apps | ||
|
|
||
| # on: | ||
| # push: | ||
| # branches: | ||
| # - main | ||
| # paths: | ||
| # - 'docs/**' | ||
| # pull_request: | ||
| # types: [opened, synchronize, reopened, closed] | ||
| # branches: | ||
| # - main | ||
| # paths: | ||
| # - 'docs/**' | ||
| # workflow_dispatch: | ||
|
|
||
| # # Sets permissions for GITHUB_TOKEN | ||
| # permissions: | ||
| # contents: read | ||
| # pull-requests: write | ||
|
|
||
| # # Allow only one concurrent deployment | ||
| # concurrency: | ||
| # group: "azure-swa" | ||
| # cancel-in-progress: false | ||
|
|
||
| # jobs: | ||
| # build_and_deploy: | ||
| # # Only run on push or if PR is not closed | ||
| # if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.action != 'closed') | ||
| # runs-on: ubuntu-latest | ||
| # name: Build and Deploy | ||
| # steps: | ||
| # - name: Checkout | ||
| # uses: actions/checkout@v4 | ||
| # with: | ||
| # fetch-depth: 1 | ||
|
|
||
| # - name: Setup .NET | ||
| # uses: actions/setup-dotnet@v4 | ||
| # with: | ||
| # dotnet-version: 8.x | ||
|
|
||
| # - name: Install DocFX | ||
| # run: dotnet tool update -g docfx | ||
|
|
||
| # - name: Build documentation | ||
| # run: docfx docs/docfx.json | ||
|
|
||
| # - name: Deploy to Azure Static Web Apps | ||
| # id: deploy | ||
| # uses: Azure/static-web-apps-deploy@v1 | ||
| # with: | ||
| # azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }} | ||
| # repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
| # action: upload | ||
| # app_location: "docs/_site" | ||
| # api_location: "" | ||
| # output_location: "" | ||
| # skip_app_build: true | ||
|
|
||
| # close_pull_request: | ||
| # # Only run when PR is closed | ||
| # if: github.event_name == 'pull_request' && github.event.action == 'closed' | ||
| # runs-on: ubuntu-latest | ||
| # name: Close Pull Request | ||
| # steps: | ||
| # - name: Close Pull Request | ||
| # uses: Azure/static-web-apps-deploy@v1 | ||
| # with: | ||
| # azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }} | ||
| # action: close |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,171 @@ | ||
| # Azure Static Web Apps Deployment - Quick Start | ||
|
|
||
| This guide walks you through deploying your DocFX wiki to Azure Static Web Apps in minutes. | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Azure subscription ([free trial available](https://azure.microsoft.com/free/)) | ||
| - Azure CLI installed ([install guide](https://learn.microsoft.com/cli/azure/install-azure-cli)) | ||
| - GitHub repository access (for setting secrets) | ||
|
|
||
| ## Step-by-Step Deployment | ||
|
|
||
| ### 1. Clone and Customize | ||
|
|
||
| ```bash | ||
| # Clone the repository | ||
| git clone https://github.com/YOUR-USERNAME/docfx-wiki.git | ||
| cd docfx-wiki | ||
|
|
||
| # Edit the parameters file | ||
| cd infra | ||
| nano bicep.parameters.json # or use your preferred editor | ||
| ``` | ||
|
|
||
| **Edit these values in `bicep.parameters.json`:** | ||
|
|
||
| ```json | ||
| { | ||
| "parameters": { | ||
| "staticWebAppName": { | ||
| "value": "my-unique-wiki-name" // ⚠️ Must be globally unique | ||
| }, | ||
| "location": { | ||
| "value": "eastus2" // Choose your preferred region | ||
| }, | ||
| "sku": { | ||
| "value": "Free" // Free or Standard | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### 2. Login to Azure | ||
|
|
||
| ```bash | ||
| az login | ||
| ``` | ||
|
|
||
| ### 3. Deploy Infrastructure (One Command!) | ||
|
|
||
| ```bash | ||
| # Create resource group and deploy in one go | ||
| RESOURCE_GROUP="rg-docfx-wiki" | ||
| LOCATION="eastus2" | ||
|
|
||
| az group create --name $RESOURCE_GROUP --location $LOCATION && \ | ||
| az deployment group create \ | ||
| --resource-group $RESOURCE_GROUP \ | ||
| --template-file main.bicep \ | ||
| --parameters bicep.parameters.json | ||
| ``` | ||
|
|
||
| ✅ **Success!** Your Azure Static Web App is now created. | ||
|
|
||
| ### 4. Get Your Deployment Token | ||
|
|
||
| ```bash | ||
| DEPLOYMENT_TOKEN=$(az deployment group show \ | ||
| --resource-group $RESOURCE_GROUP \ | ||
| --name main \ | ||
| --query properties.outputs.deploymentToken.value \ | ||
| --output tsv) | ||
|
|
||
| echo "Your deployment token: $DEPLOYMENT_TOKEN" | ||
| ``` | ||
|
|
||
| ⚠️ **Important:** Copy this token - you'll need it in the next step. | ||
|
|
||
| ### 5. Add Secret to GitHub | ||
|
|
||
| 1. Go to your GitHub repository | ||
| 2. Click **Settings** → **Secrets and variables** → **Actions** | ||
| 3. Click **New repository secret** | ||
| 4. Set: | ||
| - **Name:** `AZURE_STATIC_WEB_APPS_API_TOKEN` | ||
| - **Value:** Paste the deployment token from step 4 | ||
| 5. Click **Add secret** | ||
|
|
||
| ### 6. Trigger Deployment | ||
|
|
||
| Option A: Push to main branch | ||
| ```bash | ||
| git add . | ||
| git commit -m "Update documentation" | ||
| git push origin main | ||
| ``` | ||
|
|
||
| Option B: Manual trigger | ||
| 1. Go to **Actions** tab in GitHub | ||
| 2. Select **Deploy to Azure Static Web Apps** | ||
| 3. Click **Run workflow** | ||
|
|
||
| ### 7. View Your Site | ||
|
|
||
| Get your site URL: | ||
| ```bash | ||
| az staticwebapp show \ | ||
| --name $(jq -r '.parameters.staticWebAppName.value' bicep.parameters.json) \ | ||
| --resource-group $RESOURCE_GROUP \ | ||
| --query defaultHostname \ | ||
| --output tsv | ||
| ``` | ||
|
|
||
| Or find it in the Azure Portal: | ||
| - Go to [portal.azure.com](https://portal.azure.com) | ||
| - Navigate to your resource group | ||
| - Click on your Static Web App | ||
| - Copy the URL from the Overview page | ||
|
|
||
| ## What Happens Next? | ||
|
|
||
| ✨ **Automatic Deployments:** Every time you push changes to the `docs/**` folder on the `main` branch, GitHub Actions will: | ||
| 1. Build your DocFX site | ||
| 2. Deploy it to Azure Static Web Apps | ||
| 3. Make it available at your custom URL | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### "Static Web App name already exists" | ||
| - Change `staticWebAppName` in `bicep.parameters.json` to a unique value | ||
| - Re-run the deployment command | ||
|
|
||
| ### "Deployment token not working" | ||
| - Regenerate the token: | ||
| ```bash | ||
| az staticwebapp secrets list \ | ||
| --name YOUR_APP_NAME \ | ||
| --resource-group $RESOURCE_GROUP | ||
| ``` | ||
| - Update the GitHub secret with the new token | ||
|
|
||
| ### "Workflow not triggering" | ||
| - Check that the workflow file exists: `.github/workflows/azure-swa-deploy.yml` | ||
| - Verify the secret name is exactly: `AZURE_STATIC_WEB_APPS_API_TOKEN` | ||
| - Check workflow runs under the **Actions** tab | ||
|
|
||
| ### "Site shows 404 or not found" | ||
| - Wait 2-3 minutes after first deployment | ||
| - Clear your browser cache | ||
| - Check the deployment status in GitHub Actions | ||
|
|
||
| ## Cleanup | ||
|
|
||
| To delete all resources and stop charges: | ||
|
|
||
| ```bash | ||
| az group delete --name $RESOURCE_GROUP --yes --no-wait | ||
| ``` | ||
|
|
||
| ## Next Steps | ||
|
|
||
| - 📝 [Edit your wiki content](../docs/content/) | ||
| - 🎨 [Customize DocFX templates](../docs/docfx.json) | ||
| - 🔧 [Configure routing](../staticwebapp.config.json) | ||
| - 📊 [Monitor with Application Insights](https://learn.microsoft.com/azure/static-web-apps/monitor) | ||
|
|
||
| ## Support | ||
|
|
||
| - 📖 [Azure Static Web Apps Documentation](https://learn.microsoft.com/azure/static-web-apps/) | ||
| - 💬 [GitHub Discussions](https://github.com/YOUR-USERNAME/docfx-wiki/discussions) | ||
| - 🐛 [Report Issues](https://github.com/YOUR-USERNAME/docfx-wiki/issues) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.