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 deploy step of a job with building docs #1631

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 26 additions & 14 deletions .github/workflows/build-sphinx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ on:
types: [opened, synchronize, reopened, closed]

env:
GH_BOT_NAME: 'github-actions[bot]'
GH_BOT_EMAIL: 'github-actions[bot]@users.noreply.github.com'
GH_EVENT_OPEN_PR_UPSTREAM: ${{ github.event_name == 'pull_request' && github.event.action != 'closed' &&
github.event.pull_request && !github.event.pull_request.head.repo.fork }}
GH_EVENT_PUSH_UPSTREAM: ${{ github.ref == 'refs/heads/master' && github.event_name == 'push' &&
github.event.ref == 'refs/heads/master' && github.event.repository && !github.event.repository.fork }}
PUBLISH_DIR: doc/_build/html/

defaults:
Expand Down Expand Up @@ -125,36 +131,40 @@ jobs:
working-directory: 'dpnp/backend/doc'

- name: Copy backend docs
run: cp -r dpnp/backend/doc/html doc/_build/html/backend_doc
run: cp -r dpnp/backend/doc/html ${{ env.PUBLISH_DIR }}/backend_doc

# https://github.com/marketplace/actions/github-pages-action
# The step is only used to build docs while pushing a PR to "master"
- name: Deploy docs
if: |
github.event.pull_request && !github.event.pull_request.head.repo.fork &&
(github.ref == 'refs/heads/master' || (startsWith(github.ref, 'refs/heads/release') == true) || github.event_name == 'push' && contains(github.ref, 'refs/tags/'))
if: env.GH_EVENT_PUSH_UPSTREAM
uses: peaceiris/actions-gh-pages@v3.9.3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ${{ env.PUBLISH_DIR }}
keep_files: true
commit_message: ${{ github.event.head_commit.message }}
publish_branch: gh-pages
user_name: ${{ env.GH_BOT_NAME }}
user_email: ${{ env.GH_BOT_EMAIL }}

# The step is only used to build docs while pushing to PR branch
- name: Publish pull-request docs
if: |
github.event.pull_request && !github.event.pull_request.head.repo.fork && github.event.action != 'closed'
if: env.GH_EVENT_OPEN_PR_UPSTREAM
uses: peaceiris/actions-gh-pages@v3.9.3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ${{ env.PUBLISH_DIR }}
destination_dir: ./pull/${{ github.event.number }}
allow_empty_commit : true
keep_files: true
commit_message: ${{ github.event.head_commit.message }}
commit_message: ${{ github.event.pull_request.title }}
publish_branch: gh-pages
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
user_name: ${{ env.GH_BOT_NAME }}
user_email: ${{ env.GH_BOT_EMAIL }}

# The step is only used to build docs while pushing to PR branch
- name: Comment with URL to published pull-request docs
if: |
github.event.pull_request && !github.event.pull_request.head.repo.fork && github.event.action != 'closed'
if: env.GH_EVENT_OPEN_PR_UPSTREAM
env:
PR_NUM: ${{ github.event.number }}
uses: mshick/add-pr-comment@v2.8.1
Expand All @@ -163,9 +173,11 @@ jobs:
View rendered docs @ https://intelpython.github.io/dpnp/pull/${{ env.PR_NUM }}/index.html
allow-repeats: false

# The job is only used to build docs when PR is closed (action from PR branch)
clean:
if: |
github.event.pull_request && !github.event.pull_request.head.repo.fork && github.event.action == 'closed'
github.event_name == 'pull_request' && github.event.action == 'closed' &&
github.event.pull_request && !github.event.pull_request.head.repo.fork

needs: build-and-deploy

Expand All @@ -185,8 +197,8 @@ jobs:
git checkout --track tokened_docs/gh-pages
echo `pwd`
[ -d pull/${PR_NUM} ] && git rm -rf pull/${PR_NUM}
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git config --global user.name ${{ env.GH_BOT_NAME }}
git config --global user.email ${{ env.GH_BOT_EMAIL }}
git commit -m "Removing docs for closed pull request ${PR_NUM}"
git push tokened_docs gh-pages

Expand Down
Loading