added 2-factor design #640
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
name: Build and Deploy GitHub Pages | |
# Build site for commits pushed to all branches | |
# Deploy only if on default branch | |
on: | |
push: | |
pull_request: | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
fetch-depth: 0 # Fetch all history for all branches and tags | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9.x' # same as macOS | |
cache: pip | |
- name: Install dependencies | |
run: pip install -r requirements.txt | |
# - name: Debug - Show biotips file status | |
# run: | | |
# echo 'Biotips submodule directory listing:' | |
# ls -lh docs/workshops/biotips/ || echo 'biotips dir missing' | |
# echo | |
# echo 'File type:' | |
# file docs/workshops/biotips/setup-cannon.md || echo 'setup-cannon.md missing' | |
# echo | |
# echo 'First 20 lines:' | |
# head -20 docs/workshops/biotips/setup-cannon.md || echo 'setup-cannon.md missing' | |
- name: Build site | |
run: mkdocs build | |
- name: Patch jupyter HTML with metadata # Adds title and description to HTML rendered from jupyter notebooks | |
run: python scripts/add_jupyter_meta.py | |
- name: Upload site/ | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: site | |
link-checker: | |
runs-on: ubuntu-latest | |
needs: build | |
permissions: | |
actions: read | |
steps: | |
# Cache lychee external URL results for 30 days | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Download site | |
uses: actions/download-artifact@v4 | |
with: | |
name: github-pages | |
- name: Extract artifact | |
run: tar -xf artifact.tar && rm artifact.tar | |
# https://github.com/lycheeverse/lychee-action#utilising-the-cache-feature | |
- name: Restore lychee cache | |
id: restore-cache | |
uses: actions/cache/restore@v3 | |
with: | |
path: .lycheecache | |
key: cache-lychee-${{ github.sha }} | |
restore-keys: cache-lychee- | |
- name: Run lychee | |
uses: lycheeverse/[email protected] | |
with: | |
args: "--base . --cache --config .github/workflows/lychee.toml -- 'site/**/*.html' 'site/**/*.css'" | |
fail: true | |
- name: Save lychee cache | |
uses: actions/cache/save@v3 | |
if: always() | |
with: | |
path: .lycheecache | |
key: ${{ steps.restore-cache.outputs.cache-primary-key }} | |
deploy: | |
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) | |
runs-on: ubuntu-latest | |
needs: build | |
permissions: | |
pages: write | |
id-token: write | |
actions: read | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |