Skip to content

add publish workflow #36

add publish workflow

add publish workflow #36

name: Lint, Test & Docs
on:
push:
pull_request:
# to trigger manually with webhook
# curl -X POST https://api.github.com/repos/:owner/:repo/dispatches \
# -H 'Accept: application/vnd.github.everest-preview+json' \
# -H 'Authorization: token TOKEN_VALUE_HERE' \
# --data '{"event_type":"lint-test-docs","client_payload":{}}'
repository_dispatch:
types: [lint-test-docs]
jobs:
lint:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: lint
run: |
docker-compose run --rm dev
env:
RUN_TEST: no
test:
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
python: ["3.7", "3.8", "3.9", "3.10"]
requirements:
- "flask>=1.0,<1.1 werkzeug<2.1 jinja2<3 markupsafe<2.1 itsdangerous<2.1"
- "flask>=1.1,<1.2 markupsafe==2.0.1"
- "flask>=2.0,<2.1"
- "flask>=2.1,<2.2"
- "flask>=2.2,<2.3"
experimental: [false]
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: test
run: |
docker-compose run --rm dev
env:
REQUIREMENTS: ${{ matrix.requirements }}
CHECK_STYLE: no
DEV_IMAGE: python:${{ matrix.python }}
# build and publish docs
docs:
if: github.event_name != 'pull_request'
needs: [lint, test]
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: gen docs
run: |
docker-compose run --rm docs-gen
# the target folder to be deployed on the gh_pages branch
- name: set target folder
id: set_target_folder
run: |
GIT_BRANCH=$(echo ${GITHUB_REF} | sed -e "s/refs\/heads\///g" | sed -e "s/refs\/tags\///g" \
| sed -e "s/refs\/pull\///g")
echo "\$GIT_BRANCH: $GIT_BRANCH"
if [[ $GIT_BRANCH == 'master' ]] || [[ $GIT_BRANCH == 'main' ]] ; then
TARGET_FOLDER=.
elif [[ $GIT_BRANCH == 'develop' ]] ; then
TARGET_FOLDER=develop
elif [[ $GIT_BRANCH =~ ^v[0-9.]+[0-9.a-z\-]*$ ]]; then
TARGET_FOLDER=${GIT_BRANCH:1}
elif [[ $GIT_BRANCH =~ ^[0-9.]+[0-9.a-z\-]*$ || $GIT_BRANCH =~ ^releases\/[v0-9.]+[0-9.a-z\-]*$ ]]; then
TARGET_FOLDER=$GIT_BRANCH
fi
echo "\$TARGET_FOLDER: $TARGET_FOLDER"
echo "::set-output name=target_folder::$TARGET_FOLDER"
- name: publish docs
uses: JamesIves/[email protected]
if: steps.set_target_folder.outputs.target_folder != ''
with:
branch: gh-pages
folder: docs/_build/html
clean: false
target-folder: ${{ steps.set_target_folder.outputs.target_folder }}