Created
March 11, 2020 14:46
-
-
Save zerolab/bfff700fcd476bb513ae6a920aad056d to your computer and use it in GitHub Desktop.
Sample mkdocs deployment to GitHub Pages action
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: 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