Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zerolab/bfff700fcd476bb513ae6a920aad056d to your computer and use it in GitHub Desktop.
Save zerolab/bfff700fcd476bb513ae6a920aad056d to your computer and use it in GitHub Desktop.
Sample mkdocs deployment to GitHub Pages action
name: MkDocs to GitHub Pages
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v1
with:
python-version: '3.6'
architecture: 'x64'
- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-dev.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install -r ./requirements-dev.txt
- run: mkdocs build
- name: Deploy
run: |
github_token: ${{ secrets.GITHUB_TOKEN }}
cd docs_rendered
git init
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git remote add origin "https://x-access-token:${github_token}@github.com:${GITHUB_REPOSITORY}.git"
git checkout gh-pages || git checkout --orphan gh-pages
git add --all
timestamp=$(date -u)
git commit -m "Automated deployment: ${timestamp} ${GITHUB_SHA}"
git push origin gh-pages --force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment