deploy #7897
This file contains 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
--- | |
# 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 | |
on: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: 25/20 * * * * | |
jobs: | |
test-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python 3.8 | |
uses: actions/setup-python@v3 | |
with: | |
python-version: 3.8 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install \ | |
-r ./src/requirements.txt \ | |
-r ./tests/requirements.txt | |
- name: Test with pytest | |
run: | | |
PYTHONPATH=src/ pytest -v | |
- name: Build GH pages | |
run: | | |
python "${GITHUB_WORKSPACE}/src/build.py" | |
cp -r "${GITHUB_WORKSPACE}/src/build/html" ${{ runner.temp }}/ | |
- uses: actions/checkout@v3 | |
with: | |
ref: gh-pages | |
- name: Commit updates | |
id: commit | |
continue-on-error: true # for expected error condition, see below | |
run: | | |
rm -rfv "${GITHUB_WORKSPACE}/*" | |
cp -r ${{ runner.temp }}/html/* "${GITHUB_WORKSPACE}"/ | |
git add -A . | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
# The following command fails if there are no updates (e.g. README change): | |
git commit -m "Deploy to GitHub Pages: ${GITHUB_SHA}" | |
- name: Deploy | |
uses: ad-m/[email protected] | |
if: steps.commit.outcome == 'success' | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: gh-pages |