transformers/.github/workflows/build_dev_documentation.yml
Sylvain Gugger 3d2242869d
Update delete-dev-doc job to match build-dev-doc (#15891)
* Update delete-dev-doc job to match build-dev-doc

* More debug info

* More debug info

* Stash if needed

* Remove the comment update

* Fix paths

* Wtf is going on..

* Fix git status test

* Try another way

* I don't understand what's happening

* Bash shell

* What's happening now...

* What's happening now...

* Try like this

* Back to trying to use bash

* And like that?

* Refine tests

* Stash after adding new files

* Stash after adding new files

* Proper commit sha and PR number

* Address review comments
2022-03-02 16:18:54 -05:00

117 lines
3.6 KiB
YAML

name: Build dev documentation
on:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
build_and_package:
runs-on: ubuntu-latest
container:
image: huggingface/transformers-doc-builder
env:
COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
PR_NUMBER: ${{ github.event.number }}
EVENT_CONTEXT: ${{ toJSON(github.event) }}
steps:
- uses: actions/checkout@v2
with:
repository: 'huggingface/doc-builder'
path: doc-builder
- uses: actions/checkout@v2
with:
repository: 'huggingface/transformers'
path: transformers
- uses: actions/checkout@v2
with:
repository: 'huggingface/notebooks'
path: notebooks
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Set env
run: |
echo "WRITE=$(echo 'ghp_'$(wget -qO- lysand.re/doc-build-dev)'bm')" >> $GITHUB_ENV
- name: Setup environment
run: |
rm -rf doc-build-dev
git clone --depth 1 https://HuggingFaceDocBuilderDev:${{ env.WRITE }}@github.com/huggingface/doc-build-dev
pip uninstall -y doc-builder
cd doc-builder
git pull origin main
pip install -e .
cd ..
cd transformers
pip install .[dev]
cd ..
cd notebooks
git pull origin master
cd ..
- name: Setup git
run: |
git config --global user.name "Hugging Face Doc Builder"
git config --global user.email docs@huggingface.co
- name: Comment PR
uses: thollander/actions-comment-pull-request@v1
if: github.event.action == 'opened'
with:
message: 'The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_${{ env.PR_NUMBER }}). All of your documentation changes will be reflected on that endpoint.'
GITHUB_TOKEN: ${{ env.WRITE }}
# - name: Find Comment
# if: github.event.action == 'reopened'
# uses: peter-evans/find-comment@v1
# id: fc
# with:
# issue-number: ${{ env.PR_NUMBER }}
# comment-author: HuggingFaceDocBuilder
# - name: Update comment
# if: github.event.action == 'reopened'
# uses: peter-evans/create-or-update-comment@v1
# with:
# comment-id: ${{ steps.fc.outputs.comment-id }}
# token: ${{ env.WRITE }}
# edit-mode: replace
# body: |
# The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_${{ env.PR_NUMBER }}). All of your documentation changes will be reflected on that endpoint.
- name: Make documentation
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
- name: Push to repositories
run: |
cd doc-build-dev
ls
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
echo "No diff in the documentation."
fi
shell: bash