Skip to content

Commit 3d22428

Browse files
authored
Update delete-dev-doc job to match build-dev-doc (huggingface#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
1 parent 89be34c commit 3d22428

File tree

2 files changed

+66
-53
lines changed

2 files changed

+66
-53
lines changed

.github/workflows/build_dev_documentation.yml

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
container:
1414
image: huggingface/transformers-doc-builder
1515
env:
16+
COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
1617
PR_NUMBER: ${{ github.event.number }}
1718
EVENT_CONTEXT: ${{ toJSON(github.event) }}
1819

@@ -73,23 +74,23 @@ jobs:
7374
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.'
7475
GITHUB_TOKEN: ${{ env.WRITE }}
7576

76-
- name: Find Comment
77-
if: github.event.action == 'reopened'
78-
uses: peter-evans/find-comment@v1
79-
id: fc
80-
with:
81-
issue-number: ${{ env.PR_NUMBER }}
82-
comment-author: HuggingFaceDocBuilder
83-
84-
- name: Update comment
85-
if: github.event.action == 'reopened'
86-
uses: peter-evans/create-or-update-comment@v1
87-
with:
88-
comment-id: ${{ steps.fc.outputs.comment-id }}
89-
token: ${{ env.WRITE }}
90-
edit-mode: replace
91-
body: |
92-
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.
77+
# - name: Find Comment
78+
# if: github.event.action == 'reopened'
79+
# uses: peter-evans/find-comment@v1
80+
# id: fc
81+
# with:
82+
# issue-number: ${{ env.PR_NUMBER }}
83+
# comment-author: HuggingFaceDocBuilder
84+
85+
# - name: Update comment
86+
# if: github.event.action == 'reopened'
87+
# uses: peter-evans/create-or-update-comment@v1
88+
# with:
89+
# comment-id: ${{ steps.fc.outputs.comment-id }}
90+
# token: ${{ env.WRITE }}
91+
# edit-mode: replace
92+
# body: |
93+
# 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.
9394

9495
- name: Make documentation
9596
env:
@@ -103,6 +104,14 @@ jobs:
103104
run: |
104105
cd doc-build-dev
105106
ls
106-
git add .
107-
git commit -m "Updated with commit ${{ github.sha }} See: https://github.com/huggingface/transformers/commit/${{ github.sha }}"
108-
git push origin main
107+
git status
108+
109+
if [[ `git status --porcelain` ]]; then
110+
git add .
111+
git stash && git pull && git stash apply
112+
git commit -m "Updated with commit $COMMIT_SHA See: https://github.com/huggingface/transformers/commit/$COMMIT_SHA"
113+
git push origin main
114+
else
115+
echo "No diff in the documentation."
116+
fi
117+
shell: bash

.github/workflows/delete_dev_documentation.yml

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,22 @@ on:
77

88
jobs:
99
build_and_package:
10-
runs-on: [self-hosted, doc-builder]
10+
runs-on: ubuntu-latest
1111
container:
12-
image: huggingface/doc-builder-transformers
13-
options: "-v /home/github_actions:/mnt"
12+
image: huggingface/transformers-doc-builder
13+
1414
env:
1515
PR_NUMBER: ${{ github.event.number }}
1616

1717
steps:
18-
- uses: actions/checkout@v2
1918
- name: Set env
20-
run: echo "WRITE=$(cat /mnt/WRITE)" >> $GITHUB_ENV
21-
22-
- uses: actions/checkout@v2
23-
with:
24-
repository: 'huggingface/doc-build-dev'
25-
path: doc-build-dev
26-
token: ${{ env.WRITE }}
19+
run: |
20+
echo "WRITE=$(echo 'ghp_'$(wget -qO- lysand.re/doc-build-dev)'bm')" >> $GITHUB_ENV
21+
22+
- name: Setup environment
23+
run: |
24+
rm -rf doc-build-dev
25+
git clone --depth 1 https://HuggingFaceDocBuilderDev:${{ env.WRITE }}@github.com/huggingface/doc-build-dev
2726
2827
- name: Setup git
2928
run: |
@@ -33,27 +32,32 @@ jobs:
3332
- name: Push to repositories
3433
run: |
3534
cd doc-build-dev
36-
ls
3735
rm -rf transformers/pr_$PR_NUMBER
3836
ls
39-
git add .
40-
git commit -m "Closed PR ${GITHUB_REF##*/}"
41-
git push origin main
42-
43-
- name: Find Comment
44-
if: ${{ always() }}
45-
uses: peter-evans/find-comment@v1
46-
id: fc
47-
with:
48-
issue-number: ${{ env.PR_NUMBER }}
49-
comment-author: HuggingFaceDocBuilder
50-
51-
- name: Update comment
52-
if: ${{ always() }}
53-
uses: peter-evans/create-or-update-comment@v1
54-
with:
55-
comment-id: ${{ steps.fc.outputs.comment-id }}
56-
token: ${{ env.WRITE }}
57-
edit-mode: replace
58-
body: |
59-
_The documentation is not available anymore as the PR was closed or merged._
37+
git status
38+
if [[ `git status --porcelain` ]]; then
39+
git add .
40+
git commit -m "Closed PR $PR_NUMBER"
41+
git push origin main
42+
else
43+
echo "Branch was already deleted, nothing to do."
44+
fi
45+
shell: bash
46+
47+
# - name: Find Comment
48+
# if: ${{ always() }}
49+
# uses: peter-evans/find-comment@v1
50+
# id: fc
51+
# with:
52+
# issue-number: ${{ env.PR_NUMBER }}
53+
# comment-author: HuggingFaceDocBuilder
54+
55+
# - name: Update comment
56+
# if: ${{ always() }}
57+
# uses: peter-evans/create-or-update-comment@v1
58+
# with:
59+
# comment-id: ${{ steps.fc.outputs.comment-id }}
60+
# token: ${{ env.WRITE }}
61+
# edit-mode: replace
62+
# body: |
63+
# _The documentation is not available anymore as the PR was closed or merged._

0 commit comments

Comments
 (0)