Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update delete-dev-doc job to match build-dev-doc #15891

Merged
merged 21 commits into from Mar 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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._