Skip to content

rebuild_docs

rebuild_docs #19

Workflow file for this run

name: Deploy MkDocs to Documentation Repo
on:
push:
branches:
- main
repository_dispatch:
types: [rebuild_docs]
env:
PYTHON_VERSION: '3.x'
MKDOCS_SITE_DIR: 'site'
DOCS_BRANCH: 'gh-pages'
DOCS_SUBDIR: 'packaging-publishing'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install MkDocs and dependencies
run: |
pip install mkdocs mkdocs-material mkdocstrings
- name: Build the MkDocs site
run: mkdocs build
- name: Generate GitHub App token
id: generate_token
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
installation_id: ${{ secrets.INSTALLATION_ID }}
- name: Clone the Documentation Repo
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git clone --branch ${{ env.DOCS_BRANCH }} https://x-access-token:${{ steps.generate_token.outputs.token }}@github.com/acceleratescience/workshops.git temp_docs
- name: Deploy to Documentation Repo
run: |
# Ensure the target directory exists
mkdir -p temp_docs/${{ env.DOCS_SUBDIR }}
# Sync the built site to the target directory
rsync -av --delete ${{ env.MKDOCS_SITE_DIR }}/ temp_docs/${{ env.DOCS_SUBDIR }}/
# Commit and push changes
cd temp_docs
git add .
git diff-index --quiet HEAD || (git stash && git pull --rebase origin ${{ env.DOCS_BRANCH }} && git stash pop)
git add .
git diff-index --quiet HEAD || git commit -m "Update ${{ env.DOCS_SUBDIR }} workshops"
git push origin ${{ env.DOCS_BRANCH }}
- name: Clean up
if: always()
run: |
rm -rf temp_docs