Skip to content

Deploy wiki to Pages #12

Deploy wiki to Pages

Deploy wiki to Pages #12

Workflow file for this run

# This workflow builds the wiki and uploads it to a staging repository.
# The staging repository is used as more than one workflow can modify the website's content.
# A gh-pages branch could have been used, but this wasn't possible as it would trigger webhooks.
# So the goal here is to create the outputs, write them to the remote repo,
# then grab the entire staging repo and publish it, since it will contain all the merged content.
name: Deploy wiki to Pages
on:
workflow_dispatch:
inputs:
version:
description: 'The BotCommands version this wiki deployment is for'
required: true
alias:
description: 'The version alias for this deployment'
required: true
default: '3.X'
type: choice
options:
- 2.X
- 3.X
is_latest:
description: 'Is this version the latest stable release?'
required: true
default: false
type: boolean
# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
staging:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure Git user
run: |
git config user.name GitHub Actions
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
# https://github.com/webfactory/ssh-agent#support-for-github-deploy-keys
# https://github.com/webfactory/ssh-agent#creating-ssh-keys
- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.STAGING_REPO_SSH_KEY }}
- name: Add pages remote
run: |
git remote add staging-remote [email protected]:freya022/BotCommands-Pages-Staging.git
git fetch staging-remote staging:staging --depth=1
- uses: actions/setup-python@v4
with:
python-version: 3.x
cache: 'pip'
- name: Install Python dependencies
working-directory: ./wiki
run: pip install -r requirements.txt
- name: Generate wiki
working-directory: ./wiki
run: mike deploy ${{ inputs.version }} ${{ inputs.alias }} --update-aliases --branch staging
- name: Update latest alias
if: ${{ inputs.is_latest }}
working-directory: ./wiki
run: mike set-default ${{ inputs.alias }} --branch staging
# The wiki is uploaded in the staging repository root
- name: Push to staging repository
run: |
git push staging-remote staging:staging
# Same as in docs.yml
deploy:
needs: staging
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
# The entire staging repository (docs + wiki) gets deployed
- uses: actions/checkout@v4
with:
ssh-key: ${{ secrets.STAGING_REPO_SSH_KEY }}
repository: freya022/BotCommands-Pages-Staging
ref: staging
- name: Upload staging repository
uses: actions/upload-pages-artifact@v2
with:
# Upload entire repository
path: .
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2