-
Notifications
You must be signed in to change notification settings - Fork 889
Add Publish from Azure DevOps #10213
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 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| # Setting up DocFX with Azure DevOps to Deploy to GitHub Pages | ||
|
|
||
|
|
||
| ### 1. **Create a GitHub Personal Access Token (PAT)** | ||
| You will need a GitHub PAT with repo permissions to allow Azure DevOps to push to the GitHub Pages branch. | ||
|
|
||
| - Go to your GitHub account > **Settings** > **Developer settings** > **Personal Access Tokens**. | ||
| - Click on **Generate new token** and select the required repo permissions. | ||
| - Save the token somewhere secure as it will be used in the Azure DevOps pipeline. | ||
|
|
||
| ### 2. **Create Azure DevOps Pipeline** | ||
|
|
||
| #### a. **Setup DocFX** | ||
| Ensure that you have a `docfx.json` configuration file in your repository. This will define how DocFX generates your documentation. | ||
|
|
||
| - Install DocFX locally on your development machine and create the configuration: | ||
|
|
||
| ```bash | ||
| docfx init -q | ||
| ``` | ||
|
|
||
| This will generate the `docfx.json` file, which you can configure to specify input and output directories, build settings, etc. | ||
|
|
||
| #### b. **Azure Pipelines YAML File** | ||
|
|
||
| Create an Azure DevOps pipeline YAML file (e.g., `azure-pipelines.yml`) in the root of your project to automate the build and deployment. | ||
|
|
||
| Here is a sample pipeline YAML configuration for DocFX: | ||
|
|
||
| ```yaml | ||
| trigger: | ||
| branches: | ||
| include: | ||
| - main # Trigger on main branch | ||
|
|
||
| pool: | ||
| vmImage: 'ubuntu-latest' # Use the latest Ubuntu VM | ||
|
|
||
| variables: | ||
| - group: GitHubPAT | ||
|
|
||
| steps: | ||
| # Step 1: Install DocFX | ||
| - task: UseDotNet@2 | ||
| inputs: | ||
| packageType: 'sdk' | ||
| version: '8.x' # Ensure you have .NET SDK installed | ||
| installationPath: $(Agent.ToolsDirectory)/dotnet | ||
|
|
||
| - script: | | ||
| dotnet tool install -g docfx | ||
| displayName: 'Install DocFX' | ||
|
|
||
| # Step 2: Build the Documentation using DocFX | ||
| - script: | | ||
| docfx build | ||
| displayName: 'Build Documentation' | ||
|
|
||
| # Step 3: Deploy to GitHub Pages | ||
| - task: Bash@3 | ||
| displayName: 'Deploy to GitHub Pages' | ||
| inputs: | ||
| targetType: 'inline' | ||
| script: | | ||
| git config --global user.email "your-email@example.com" | ||
| git config --global user.name "Your Name" | ||
| git clone --branch gh-pages https://$GITHUB_PAT@github.com/$GITHUB_REPO.git out | ||
| rm -rf out/* | ||
| cp -r _site/* out/ | ||
| cd out | ||
| git add --all | ||
| git commit -m "Update documentation" | ||
| git push origin gh-pages | ||
| env: | ||
| GITHUB_PAT: $(GITHUB_PAT) # The GitHub Personal Access Token | ||
| GITHUB_REPO: your-github-username/your-repo-name # Update with your repo details | ||
| ``` | ||
|
|
||
| #### c. **Setup Azure Pipeline Variables** | ||
|
|
||
| - Go to **Azure DevOps** > **Pipelines** > **Library**. | ||
| - Create a new pipeline variable group called GitHubPAT. | ||
| - Add a new variable named GITHUB_PAT and set the value to the GitHub Personal Access Token you created earlier. Mark this variable as secret. | ||
|
|
||
| ### 3. **Configure GitHub Pages** | ||
|
|
||
| - Go to your GitHub repository. | ||
| - Under **Settings** > **Pages**, set the source branch to gh-pages. | ||
|
|
||
| ### 4. **Run the Pipeline** | ||
|
|
||
| - Commit the azure-pipelines.yml file to your repository and trigger the pipeline. | ||
| - Azure DevOps will now: | ||
| 1. Install DocFX. | ||
| 2. Build the documentation. | ||
| 3. Deploy the documentation to the gh-pages branch in GitHub. | ||
|
|
||
| ### 5. **Access the Documentation** | ||
|
|
||
| After the pipeline finishes, your documentation will be available in the github-pages deployments. | ||
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.