Skip to content

Deploy Docs to GitHub pages #5

Deploy Docs to GitHub pages

Deploy Docs to GitHub pages #5

name: Deploy Docs to GitHub pages
on:
push:
branches: [ main ]
paths:
- 'src/FlUnit.Documentation/**'
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
# Yes, some of this should probably be separated out into a build job..
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: '8.x'
- name: Publish Documentation Project to 'release' folder
run: dotnet publish src/FlUnit.Documentation/FlUnit.Documentation.csproj -c Release -o release --nologo
- name: Set href of base tag in index.html to match GitHub pages subdirectory for repo
run: sed -i 's/<base href="\/" \/>/<base href="\/FlUnit\/" \/>/g' release/wwwroot/index.html
# copy index.html to 404.html to serve the same file when a file is not found
- name: copy index.html to 404.html
run: cp release/wwwroot/index.html release/wwwroot/404.html
# add .nojekyll file to tell GitHub pages to not treat this as a Jekyll project. (Allow files and folders starting with an underscore)
- name: Add .nojekyll file
run: touch release/wwwroot/.nojekyll
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: release/wwwroot
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2