Skip to content

Commit

Permalink
Update delete-dev-doc job to match build-dev-doc (#15891)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
sgugger committed Mar 2, 2022
1 parent 89be34c commit 3d22428
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 53 deletions.
49 changes: 29 additions & 20 deletions .github/workflows/build_dev_documentation.yml
Expand Up @@ -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) }}

Expand Down Expand Up @@ -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:
Expand All @@ -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
70 changes: 37 additions & 33 deletions .github/workflows/delete_dev_documentation.yml
Expand Up @@ -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: |
Expand All @@ -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._

0 comments on commit 3d22428

Please sign in to comment.