From 10591399d649d4206ff3ea34fb57e1432bc851d4 Mon Sep 17 00:00:00 2001 From: Sylvain Gugger <35901082+sgugger@users.noreply.github.com> Date: Thu, 10 Mar 2022 07:44:29 -0500 Subject: [PATCH] Build the doc in a seperate folder then move it (#16020) * Build the doc in a seperate folder then move it * Allow job * Is this it? * Dislike comments? * Copy instead of move * Removing version built * Typos * No variable * Take _versions.yml into account * Finish main job and add dev job * Forgot the run * Fix syntax error * Execute builder from the repo * Typo --- .github/workflows/build_dev_documentation.yml | 9 ++-- .github/workflows/build_documentation.yml | 47 ++++++++++++------- 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build_dev_documentation.yml b/.github/workflows/build_dev_documentation.yml index 1617750486..4bca183249 100644 --- a/.github/workflows/build_dev_documentation.yml +++ b/.github/workflows/build_dev_documentation.yml @@ -96,19 +96,18 @@ jobs: env: NODE_OPTIONS: --max-old-space-size=6656 run: | - cd doc-build-dev && git pull - cd ../doc-builder - doc-builder build transformers ../transformers/docs/source --build_dir ../doc-build-dev --notebook_dir ../notebooks/transformers_doc --clean --version pr_$PR_NUMBER --html + doc-builder build transformers transformers/docs/source --build_dir build_dir --clean --version pr_$PR_NUMBER --html - name: Push to repositories run: | cd doc-build-dev - ls + git pull + rm -rf transformers/pr_$PR_NUMBER + mv ../build_dir/transformers/pr_$PR_NUMBER transformers/pr_$PR_NUMBER git status if [[ `git status --porcelain` ]]; then git add . - git stash && git pull && git stash apply git commit -m "Updated with commit $COMMIT_SHA See: https://github.com/huggingface/transformers/commit/$COMMIT_SHA" git push origin main else diff --git a/.github/workflows/build_documentation.yml b/.github/workflows/build_documentation.yml index 676a0b8031..3fc23c3346 100644 --- a/.github/workflows/build_documentation.yml +++ b/.github/workflows/build_documentation.yml @@ -4,6 +4,7 @@ on: push: branches: - master + - doc_builder* - doc-builder* - v*-release @@ -75,42 +76,54 @@ jobs: run: | git config --global user.name "Hugging Face Doc Builder" git config --global user.email docs@huggingface.co - + + - name: Create build directory + run: | cd doc-build - git pull origin main + git pull cd .. - - cd notebooks - git pull origin master - cd .. - + mkdir build_dir + mkdir build_dir/transformers + cp doc-build/transformers/_versions.yml build_dir/transformers + - name: Make documentation run: | cd doc-builder && - doc-builder build transformers ../transformers/docs/source --build_dir ../doc-build --notebook_dir notebooks/transformers_doc --clean --html && + doc-builder build transformers ../transformers/docs/source --build_dir ../build_dir --notebook_dir ../notebooks_dir --clean --html && cd .. env: NODE_OPTIONS: --max-old-space-size=6656 - name: Push to repositories run: | - cd doc-build && + cd doc-build + git pull + mv ../build_dir/transformers/_versions.yml transformers/ + rm -rf transformers/$(ls ../build_dir/transformers) + mv ../build_dir/transformers/$(ls ../build_dir/transformers) transformers/$(ls ../build_dir/transformers) + git status + if [[ `git status --porcelain` ]]; then - git add . && - git stash && git pull && git stash apply && - git commit -m "Updated with commit ${{ github.sha }} \n\nSee: https://github.com/huggingface/transformers/commit/${{ github.sha }}" && + git add . + git commit -m "Updated with commit ${{ github.sha }} \n\nSee: https://github.com/huggingface/transformers/commit/${{ github.sha }}" git push origin main else echo "No diff in the documentation." - fi && - cd .. && + fi + + cd .. + + cd notebooks + git pull + cp -r ../notebooks_dir/. transformers_doc/ + git status - cd notebooks && if [[ `git status --porcelain` ]]; then - git add transformers_doc && + git add transformers_doc git commit -m "Updated Transformer doc notebooks with commit ${{ github.sha }} \n\nSee: https://github.com/huggingface/transformers/commit/${{ github.sha }}" && git push origin master else echo "No diff in the notebooks." - fi && + fi + cd ..