Fix jekyll deploy #246
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
# github-pages.yml/Open GoPro, Version 2.0 (C) Copyright 2021 GoPro, Inc. (http://gopro.com/OpenGoPro). | |
# This copyright was auto-generated on Wed, Sep 1, 2021 5:05:34 PM | |
name: Jekyll Build and Deploy | |
on: | |
push: | |
branches: [main, develop] | |
workflow_dispatch: | |
jobs: | |
copyright: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.PUSH_FROM_WORKFLOW_TO_RETRIGGER }} | |
- name: Check for (and add) missing copyrights | |
shell: bash | |
run: | | |
make copyright | |
echo "NUM_MODIFIED=$(git diff --numstat | wc -l)" >> $GITHUB_ENV | |
- name: Push changes | |
if: env.NUM_MODIFIED != 0 | |
shell: bash | |
run: | | |
git config core.fileMode false | |
git config user.name github-actions | |
git config user.email [email protected] | |
git add . | |
git commit -m "updating copyrights from pre merge check in github action" | |
git push | |
check: | |
needs: copyright | |
name: Check modified files for Python SDK changes | |
runs-on: ubuntu-latest | |
outputs: | |
run_job: ${{ steps.check_files.outputs.run_job }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 2 | |
- name: Analyze modified files | |
id: check_files | |
run: | | |
echo "=============== list modified files ===============" | |
git diff --name-only HEAD^ HEAD | |
echo | |
git diff --name-only HEAD^ HEAD >files.txt | |
while IFS= read -r file; do | |
if [[ $file != demos/python/sdk_wireless_camera_control* ]]; then | |
echo "{run_job}={false}" >> $GITHUB_OUTPUT | |
else | |
echo "Found a Python SDK modified file" | |
echo "{run_job}={true}" >> $GITHUB_OUTPUT | |
break | |
fi | |
done <files.txt | |
python_sdk: | |
name: Build and Deploy Python SDK Documentation | |
needs: check | |
if: needs.check.outputs.run_job == 'true' | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
include: | |
- os: ubuntu-latest | |
path: ~/Library/Caches/pip | |
steps: | |
- name: Checkout source branch (the PR branch) | |
uses: actions/checkout@v3 | |
with: | |
path: source | |
- name: Install Dot to build Sphinx Diagrams | |
shell: bash | |
run: sudo apt-get update && sudo apt install -y graphviz | |
- name: Set up Python 3.11.4 | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.11.4 | |
- name: Restore cached pip environment | |
uses: actions/cache@v2 | |
with: | |
path: ${{ matrix.path }} | |
key: ${{ runner.os }}-3.9.10-pip-${{ hashFiles('demos/python/sdk_wireless_camera_control/poetry.lock') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Install dependencies | |
working-directory: ./source/demos/python/sdk_wireless_camera_control/ | |
run: | | |
python -m pip install --upgrade pip wheel | |
pip install nox==2023.4.22 | |
pip install nox-poetry==1.0.3 | |
pip install poetry | |
- name: Build Sphinx Documentation | |
working-directory: ./source/demos/python/sdk_wireless_camera_control/ | |
run: nox -s docs | |
- name: Checkout target branch (the gh-pages branch) | |
uses: actions/checkout@v3 | |
with: | |
ref: gh-pages | |
path: target | |
- name: Deploy to Github Pages | |
run: | | |
rm -rf ./target/python_sdk | |
mkdir -p ./target/python_sdk | |
cp -r ./source/demos/python/sdk_wireless_camera_control/docs/build/. ./target/python_sdk | |
cd ./target/python_sdk | |
git add . | |
git config user.name github-actions | |
git config user.email [email protected] | |
git commit --allow-empty -m "sphinx build from Action ${GITHUB_SHA}" | |
git push | |
jekyll: | |
name: Build and Deploy Jekyll Site | |
needs: [copyright, check, python_sdk] | |
if: always() | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout source branch (the PR branch) | |
uses: actions/checkout@v3 | |
with: | |
path: source | |
- name: Checkout target branch (the gh-pages branch) | |
uses: actions/checkout@v3 | |
with: | |
ref: gh-pages | |
path: target | |
- name: Log in to the Container registry | |
uses: docker/[email protected] | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build Github Pages | |
shell: bash | |
working-directory: ./source | |
run: | | |
if [[ ${{ github.repository }} == gopro/OpenGoPro ]]; then | |
make build | |
else | |
make build BUILD_HOST_URL=${{ secrets.STAGING_GH_PAGES_SITE }} BUILD_BASE_URL="\'\'" | |
fi | |
- name: Deploy to Github Pages | |
run: | | |
cp -r ./source/docs/_site/* ./target | |
cd ./target | |
git add . | |
git config user.name github-actions | |
git config user.email [email protected] | |
git commit --allow-empty -m "Github Pages build from Action ${GITHUB_SHA}" | |
git push |