Change default brnch to main for githubpages. #154
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
name: github-pages-app-dev | ||
on: | ||
push: | ||
branches: | ||
- app/dev | ||
#TRIGGER on PR if changes made to below file-paths. | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
branches: | ||
- main | ||
paths: | ||
- "src/db.py" | ||
- "src/requirements.txt" | ||
- "src/docs/conf.py" | ||
- "src/docs/Makefile" | ||
- "src/docs/make.bat" | ||
- "src/docs/_static/styles.css" | ||
- "src/docs/_static/intel.css" | ||
- "src/docs/_static/assets/logo-energyblue-white.svg" | ||
- "src/docs/_static/sample_db_prd.json" | ||
- "src/docs/_static/assets/favicon.ico" | ||
- "src/docs/_static/script.js" | ||
- "src/docs/_templates/base.html" | ||
- "src/docs/_templates/index.html" | ||
# defaults: | ||
# run: | ||
# working-directory: src | ||
jobs: | ||
pages: | ||
name: Build GitHub Pages | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.8" | ||
# - run: find | sort | ||
- uses: actions/checkout@v3 | ||
# with: | ||
# path: app/dev | ||
# Adding above 2 lines forces pre-pending filepaths below w/ 'app/dev/filepath' | ||
- uses: actions/checkout@v3 | ||
name: Check out main | ||
with: | ||
ref: 'refs/heads/main | ||
path: main | ||
# TODO: change to 'python3 app/dev/src/db.py main' per actions/checkout@3 | ||
- name: Build JSON DB | ||
run: | | ||
python3 -m pip install -r src/requirements.txt | ||
echo main | ||
python3 src/db.py main | ||
- name: Remove JSON pre-prod | ||
run: | | ||
rm -rf src/docs/sample_db_pre.json | ||
- name: Build Sphinx | ||
run: | | ||
python3 -m pip install -r src/requirements.txt | ||
python3 -m sphinx -W -b html src/docs/ src/docs/_build/ | ||
echo $PWD | ||
echo ${{ github.ref }} | ||
- name: Add GPU-Occupancy-Calculator | ||
env: | ||
GPU_OCC_CALC: src/docs/_build/Tools/GPU-Occupancy-Calculator/ | ||
run: | | ||
mkdir -p ${GPU_OCC_CALC} | ||
cd ${GPU_OCC_CALC} | ||
wget https://raw.githubusercontent.com/oneapi-src/oneAPI-samples/main/Tools/GPU-Occupancy-Calculator/index.html | ||
- name: Push docs | ||
if: ${{ github.ref == 'refs/heads/app/dev' }} | ||
env: | ||
GITHUB_USER: ${{ github.actor }} | ||
GITHUB_TOKEN: ${{ github.token }} | ||
GITHUB_REPO: ${{ github.repository }} | ||
run: | | ||
cd src/docs/_build/ | ||
touch .nojekyll | ||
git init | ||
git remote add origin "https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/${GITHUB_REPO}" | ||
git add -A | ||
git status | ||
git config --global user.name "GitHub Actions" | ||
git config --global user.email "[email protected]" | ||
git commit -sm "$(date)" | ||
git branch -M gh-pages | ||
git push -u origin -f gh-pages |