diff --git a/.github/workflows/build_dev_documentation.yml b/.github/workflows/build_dev_documentation.yml index 4e9f1e171acff..43b7ae15c003d 100644 --- a/.github/workflows/build_dev_documentation.yml +++ b/.github/workflows/build_dev_documentation.yml @@ -13,6 +13,7 @@ jobs: 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) }} @@ -73,23 +74,23 @@ jobs: 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: 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: @@ -103,6 +104,14 @@ jobs: run: | cd doc-build-dev ls - git add . - git commit -m "Updated with commit ${{ github.sha }} See: https://github.com/huggingface/transformers/commit/${{ github.sha }}" - git push origin main + 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 \ No newline at end of file diff --git a/.github/workflows/delete_dev_documentation.yml b/.github/workflows/delete_dev_documentation.yml index e3e6f217405fc..98f2fb41db5cc 100644 --- a/.github/workflows/delete_dev_documentation.yml +++ b/.github/workflows/delete_dev_documentation.yml @@ -7,23 +7,22 @@ on: jobs: build_and_package: - runs-on: [self-hosted, doc-builder] + runs-on: ubuntu-latest container: - image: huggingface/doc-builder-transformers - options: "-v /home/github_actions:/mnt" + image: huggingface/transformers-doc-builder + env: PR_NUMBER: ${{ github.event.number }} steps: - - uses: actions/checkout@v2 - name: Set env - run: echo "WRITE=$(cat /mnt/WRITE)" >> $GITHUB_ENV - - - uses: actions/checkout@v2 - with: - repository: 'huggingface/doc-build-dev' - path: doc-build-dev - token: ${{ env.WRITE }} + 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 - name: Setup git run: | @@ -33,27 +32,32 @@ jobs: - name: Push to repositories run: | cd doc-build-dev - ls rm -rf transformers/pr_$PR_NUMBER ls - git add . - git commit -m "Closed PR ${GITHUB_REF##*/}" - git push origin main - - - name: Find Comment - if: ${{ always() }} - uses: peter-evans/find-comment@v1 - id: fc - with: - issue-number: ${{ env.PR_NUMBER }} - comment-author: HuggingFaceDocBuilder - - - name: Update comment - if: ${{ always() }} - uses: peter-evans/create-or-update-comment@v1 - with: - comment-id: ${{ steps.fc.outputs.comment-id }} - token: ${{ env.WRITE }} - edit-mode: replace - body: | - _The documentation is not available anymore as the PR was closed or merged._ + git status + if [[ `git status --porcelain` ]]; then + git add . + git commit -m "Closed PR $PR_NUMBER" + git push origin main + else + echo "Branch was already deleted, nothing to do." + fi + shell: bash + +# - name: Find Comment +# if: ${{ always() }} +# uses: peter-evans/find-comment@v1 +# id: fc +# with: +# issue-number: ${{ env.PR_NUMBER }} +# comment-author: HuggingFaceDocBuilder + +# - name: Update comment +# if: ${{ always() }} +# uses: peter-evans/create-or-update-comment@v1 +# with: +# comment-id: ${{ steps.fc.outputs.comment-id }} +# token: ${{ env.WRITE }} +# edit-mode: replace +# body: | +# _The documentation is not available anymore as the PR was closed or merged._