diff --git a/.github/workflows/build_documentation.yml b/.github/workflows/build_documentation.yml index a5be45cf09..cd38c45eab 100644 --- a/.github/workflows/build_documentation.yml +++ b/.github/workflows/build_documentation.yml @@ -17,11 +17,19 @@ jobs: - uses: actions/checkout@v2 with: repository: 'huggingface/doc-builder' + path: doc-builder + token: ${{ secrets.HUGGINGFACE_PUSH }} + + - uses: actions/checkout@v2 + with: + repository: 'huggingface/transformers' + path: transformers + + - uses: actions/checkout@v2 + with: + repository: 'huggingface/notebooks' + path: notebooks token: ${{ secrets.HUGGINGFACE_PUSH }} - - - name: Clone transformers - run: | - git clone https://github.com/huggingface/transformers - name: Loading cache. uses: actions/cache@v2 @@ -37,7 +45,7 @@ jobs: run: | sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev - pip install git+https://github.com/huggingface/doc-builder + pip install git+https://github.com/huggingface/doc-builder@add-install-cell pip install git+https://github.com/huggingface/transformers#egg=transformers[dev] export TORCH_VERSION=$(python -c "from torch import version; print(version.__version__.split('+')[0])") @@ -55,15 +63,37 @@ jobs: run: | git config --global user.name "Hugging Face" git config --global user.email transformers@huggingface.co + + cd doc-builder git pull origin main + cd .. + + cd notebooks + git pull origin master + cd .. - name: Make documentation run: | - doc-builder build transformers ./transformers/docs/source + doc-builder build transformers transformers/docs/source --build_dir doc-builder/build --notebook_dir notebooks/transformers_doc --clean - - name: Push to repository + - name: Push to repositories run: | - git add build - git commit -m "Updated with commit ${{ github.sha }}" - git push origin main + cd doc-builder + if [[ `git status --porcelain` ]]; then + git add build + git commit -m "Updated with commit ${{ github.sha }}" + git push origin main + else + echo "No diff in the documentation." + fi + cd .. + cd notebooks + if [[ `git status --porcelain` ]]; then + git add build + git commit -m "Updated Transformer doc notebooks with commit ${{ github.sha }}" + git push origin master + else + echo "No diff in the notebooks." + fi + cd .. diff --git a/docs/source/_config.py b/docs/source/_config.py new file mode 100644 index 0000000000..a038fc874a --- /dev/null +++ b/docs/source/_config.py @@ -0,0 +1,7 @@ +INSTALL_CONTENT = """ +# Transformers installation ! pip install transformers datasets # To install from source instead of the last release, +comment the command above and uncomment the following one. # ! pip install +git+https://github.com/huggingface/transformers.git +""" + +notebook_first_cells = [{"type": "code", "content": INSTALL_CONTENT}] \ No newline at end of file