Skip to content
Latchkey

deploy_gh_pages workflow (microsoft/maro)

The deploy_gh_pages workflow from microsoft/maro, explained and optimized by Latchkey.

C

CI health: C - fair

Point runs-on at Latchkey and get caching, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: microsoft/maro.github/workflows/deploy_gh_pages.ymlLicense MITView source

What it does

This is the deploy_gh_pages workflow from the microsoft/maro repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: deploy_gh_pages

# on:
#   push:
#     tags:
#     - "v*.*.*"

on: [ workflow_dispatch ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Set up Python 3.7
      uses: actions/setup-python@v2
      with:
        python-version: 3.7
    - name: Install docs dependencies
      run: |
        python -m pip install --upgrade pip
        pip install -U -r ./docs/requirements.docs.txt

    - name: Install build dependencies
      run: |
        pip install -r maro/requirements.build.txt

    - name: Compile cython files
      run: |
        cython ./maro/backends/backend.pyx ./maro/backends/np_backend.pyx ./maro/backends/raw_backend.pyx ./maro/backends/frame.pyx --cplus -3 -E NODES_MEMORY_LAYOUT=ONE_BLOCK -X embedsignature=True

    - name: Build maro inplace
      run: |
        python setup.py build_ext -i

    - name: make html
      env:
        PYTHONPATH: .
      run: |
        cd ./docs
        sphinx-apidoc -f -o ./source/apidoc ../maro/
        make html

    - name: Deploy
      uses: JamesIves/github-pages-deploy-action@3.6.1
      with:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        BRANCH: gh-pages # The branch the action should deploy to.
        FOLDER: docs/_build/html/ # The folder the action should deploy.
        CLEAN: true # Automatically remove deleted files from the deploy branch

#     - name: Switch to gh-pages
#       run: |
#         git checkout gh-pages

#     - name: Copy output files
#         cp -r docs/_build/html/* .

#     - name: Commit change
#         git add _images _modules _sources _static apidoc installation key_components scenarios index.html genindex.html objects.inv py-modindex.html search.html searchindex.js
#         git commit -m "update pages"
#         git push

The same workflow, on Latchkey

Estimated ~20% faster on cache hits, plus fewer wasted runs and a safer supply chain. Added and changed lines are highlighted.

# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
 
name: deploy_gh_pages
 
# on:
#   push:
#     tags:
#     - "v*.*.*"
 
on: [ workflow_dispatch ]
 
jobs:
  build:
    timeout-minutes: 30
 
    runs-on: latchkey-small
 
    steps:
    - uses: actions/checkout@v2
    - name: Set up Python 3.7
      uses: actions/setup-python@v2
      with:
        cache: 'pip'
        python-version: 3.7
    - name: Install docs dependencies
      run: |
        python -m pip install --upgrade pip
        pip install -U -r ./docs/requirements.docs.txt
 
    - name: Install build dependencies
      run: |
        pip install -r maro/requirements.build.txt
 
    - name: Compile cython files
      run: |
        cython ./maro/backends/backend.pyx ./maro/backends/np_backend.pyx ./maro/backends/raw_backend.pyx ./maro/backends/frame.pyx --cplus -3 -E NODES_MEMORY_LAYOUT=ONE_BLOCK -X embedsignature=True
 
    - name: Build maro inplace
      run: |
        python setup.py build_ext -i
 
    - name: make html
      env:
        PYTHONPATH: .
      run: |
        cd ./docs
        sphinx-apidoc -f -o ./source/apidoc ../maro/
        make html
 
    - name: Deploy
      uses: JamesIves/github-pages-deploy-action@3.6.1
      with:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        BRANCH: gh-pages # The branch the action should deploy to.
        FOLDER: docs/_build/html/ # The folder the action should deploy.
        CLEAN: true # Automatically remove deleted files from the deploy branch
 
#     - name: Switch to gh-pages
#       run: |
#         git checkout gh-pages
 
#     - name: Copy output files
#         cp -r docs/_build/html/* .
 
#     - name: Commit change
#         git add _images _modules _sources _static apidoc installation key_components scenarios index.html genindex.html objects.inv py-modindex.html search.html searchindex.js
#         git commit -m "update pages"
#         git push
 

What changed

1 third-party action is referenced by a movable tag. Pin it to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.

What Latchkey heals here

This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:

This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow