From ad7390636d78346384ab79d45a65b8a9d59116c0 Mon Sep 17 00:00:00 2001 From: Lysandre Debut Date: Thu, 20 Jan 2022 13:51:19 -0500 Subject: [PATCH] Tentative workflow improvement (#15255) --- .github/workflows/build_dev_documentation.yml | 22 ++++++++++++++-- .../workflows/delete_dev_documentation.yml | 26 ++++++++++--------- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build_dev_documentation.yml b/.github/workflows/build_dev_documentation.yml index e7e5efb845..1f2dd54ea9 100644 --- a/.github/workflows/build_dev_documentation.yml +++ b/.github/workflows/build_dev_documentation.yml @@ -35,12 +35,30 @@ jobs: - name: Comment PR uses: thollander/actions-comment-pull-request@v1 - if: github.event.action == 'opened' || github.event.action == 'reopened' + if: github.event.action == 'opened' with: - message: 'Thank you for your PR! 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.' + 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: Loading cache. uses: actions/cache@v2 id: cache diff --git a/.github/workflows/delete_dev_documentation.yml b/.github/workflows/delete_dev_documentation.yml index 64888faae0..e3e6f21740 100644 --- a/.github/workflows/delete_dev_documentation.yml +++ b/.github/workflows/delete_dev_documentation.yml @@ -40,18 +40,20 @@ jobs: git commit -m "Closed PR ${GITHUB_REF##*/}" git push origin main - - name: Comment PR - uses: thollander/actions-comment-pull-request@v1 - if: github.event.pull_request.merged == false - + - name: Find Comment + if: ${{ always() }} + uses: peter-evans/find-comment@v1 + id: fc with: - message: 'Thank you for your PR. The documentation will now be removed from the staging environment - feel free to reopen this PR to recreate it.' - GITHUB_TOKEN: ${{ env.WRITE }} - - - name: Comment PR - uses: thollander/actions-comment-pull-request@v1 - if: github.event.pull_request.merged == true + issue-number: ${{ env.PR_NUMBER }} + comment-author: HuggingFaceDocBuilder + - name: Update comment + if: ${{ always() }} + uses: peter-evans/create-or-update-comment@v1 with: - message: 'Great job merging this PR! the documentation will now be removed from the staging environment.' - GITHUB_TOKEN: ${{ env.WRITE }} + 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._