diff --git a/.github/workflows/docs_latest.yml b/.github/workflows/docs_latest.yml new file mode 100644 index 0000000000..1e6674d034 --- /dev/null +++ b/.github/workflows/docs_latest.yml @@ -0,0 +1,71 @@ +name: Build Docs for the latest + +on: + workflow_dispatch: # run on request (no need for PR) + push: + branches: + - develop + +jobs: + Build-Docs: + runs-on: ubuntu-20.04 + permissions: + contents: write + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.10" + - name: Install dependencies + run: | + python -m pip install tox + sudo apt-get install pandoc + - name: Build-Docs + run: | + tox -e build-docs + - name: Create gh-pages branch + run: | + echo RELEASE_VERSION=${GITHUB_REF#refs/*/} >> $GITHUB_ENV + echo SOURCE_NAME=${GITHUB_REF#refs/*/} >> $GITHUB_OUTPUT + echo SOURCE_BRANCH=${GITHUB_REF#refs/heads/} >> $GITHUB_OUTPUT + echo SOURCE_TAG=${GITHUB_REF#refs/tags/} >> $GITHUB_OUTPUT + existed_in_remote=$(git ls-remote --heads origin gh-pages) + + if [[ -z ${existed_in_remote} ]]; then + echo "Creating gh-pages branch" + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git checkout --orphan gh-pages + git reset --hard + touch .nojekyll + git add .nojekyll + git commit -m "Initializing gh-pages branch" + git push origin gh-pages + git checkout ${{steps.branch_name.outputs.SOURCE_NAME}} + echo "Created gh-pages branch" + else + echo "Branch gh-pages already exists" + fi + - name: Commit docs to gh-pages branch + run: | + git fetch + git checkout gh-pages + mkdir -p /tmp/docs_build + cp -r docs/build/html/* /tmp/docs_build/ + rm -rf ${{ env.RELEASE_VERSION }}/* + echo '' > index.html + mkdir -p ${{ env.RELEASE_VERSION }} + cp -r /tmp/docs_build/* ./${{ env.RELEASE_VERSION }} + ln -sfn ${{ env.RELEASE_VERSION }} latest + rm -rf /tmp/docs_build + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git add ./index.html ./latest ${{ env.RELEASE_VERSION }} + git commit -m "Update documentation" -a || true + - name: Push changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: gh-pages diff --git a/.github/workflows/docs_stable.yml b/.github/workflows/docs_stable.yml index 89a42516bd..f789f3d63a 100644 --- a/.github/workflows/docs_stable.yml +++ b/.github/workflows/docs_stable.yml @@ -1,7 +1,6 @@ name: Build Docs for releases on: - workflow_dispatch: # run on request (no need for PR) release: types: [published] @@ -20,15 +19,53 @@ jobs: with: python-version: "3.10" - name: Install dependencies - run: python -m pip install tox + run: | + python -m pip install tox + sudo apt-get install pandoc - name: Build-Docs + run: | + tox -e build-docs + - name: Create gh-pages branch run: | echo RELEASE_VERSION=${GITHUB_REF#refs/*/} >> $GITHUB_ENV - tox -e build-doc - # - name: Deploy - # uses: peaceiris/actions-gh-pages@v3 - # with: - # github_token: ${{ secrets.GITHUB_TOKEN }} - # publish_dir: ./public - # destination_dir: ${{ env.RELEASE_VERSION }} - # force_orphan: true + echo SOURCE_NAME=${GITHUB_REF#refs/*/} >> $GITHUB_OUTPUT + echo SOURCE_BRANCH=${GITHUB_REF#refs/heads/} >> $GITHUB_OUTPUT + echo SOURCE_TAG=${GITHUB_REF#refs/tags/} >> $GITHUB_OUTPUT + existed_in_remote=$(git ls-remote --heads origin gh-pages) + + if [[ -z ${existed_in_remote} ]]; then + echo "Creating gh-pages branch" + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git checkout --orphan gh-pages + git reset --hard + touch .nojekyll + git add .nojekyll + git commit -m "Initializing gh-pages branch" + git push origin gh-pages + git checkout ${{steps.branch_name.outputs.SOURCE_NAME}} + echo "Created gh-pages branch" + else + echo "Branch gh-pages already exists" + fi + - name: Commit docs to gh-pages branch + run: | + git fetch + git checkout gh-pages + mkdir -p /tmp/docs_build + cp -r docs/build/html/* /tmp/docs_build/ + rm -rf ${{ env.RELEASE_VERSION }}/* + echo '' > index.html + mkdir -p ${{ env.RELEASE_VERSION }} + cp -r /tmp/docs_build/* ./${{ env.RELEASE_VERSION }} + ln -sfn ${{ env.RELEASE_VERSION }} stable + rm -rf /tmp/docs_build + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git add ./index.html ./stable ${{ env.RELEASE_VERSION }} + git commit -m "Update documentation" -a || true + - name: Push changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: gh-pages diff --git a/.github/workflows/github_pages.yml b/.github/workflows/github_pages.yml deleted file mode 100644 index 49f0e4838a..0000000000 --- a/.github/workflows/github_pages.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: Github pages - -on: - workflow_dispatch: # run on request (no need for PR) - push: - branches: - - releases/1.1.0 - -jobs: - deploy: - runs-on: ubuntu-20.04 - permissions: - contents: write - steps: - - uses: actions/checkout@v3 - with: - submodules: recursive - fetch-depth: 0 - - - name: Setup Hugo - uses: peaceiris/actions-hugo@v2 - with: - hugo-version: '0.83.1' - extended: true - - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: '14.x' - - - name: Install npm packages - working-directory: ./site - run: | - npm ci - - - name: Set up Python 3.9 - uses: actions/setup-python@v4 - with: - python-version: 3.9 - - # click>=8.1.0 fails https://github.com/streamlit/streamlit/issues/4555 - - name: Build docs - run: | - pip install \ - 'click<8.1' \ - gitpython packaging toml Sphinx==4.2.0 sphinx-rtd-theme==1.0.0 sphinx-copybutton==0.4.0 \ - tensorflow openvino-dev sphinxcontrib-mermaid - pip install -r requirements.txt - pip install 'click<8.1' git+https://github.com/pytorch-ignite/sphinxcontrib-versioning.git@a1a1a94ca80a0233f0df3eaf9876812484901e76 - pip install -e '.[default,tf,tfds]' - sphinx-versioning -l site/source/conf.py build -r develop -w develop site/source site/static/api - python site/build_docs.py - - - name: Deploy - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./public - destination_dir: legacy - force_orphan: true