Skip to content

Try to publish generated_docs from PR sources and comment on the PR #673

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

Merged
merged 2 commits into from
Nov 10, 2021
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
68 changes: 67 additions & 1 deletion .github/workflows/generate-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened, closed]

jobs:
build-and-deploy:
Expand All @@ -14,30 +16,37 @@ jobs:
with:
access_token: ${{ github.token }}
- name: Add Intel repository
if: ${{ !github.event.pull_request || github.event.action != 'closed' }}
run: |
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
rm GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
sudo add-apt-repository "deb https://apt.repos.intel.com/oneapi all main"
sudo apt-get update
- name: Install Intel OneAPI
if: ${{ !github.event.pull_request || github.event.action != 'closed' }}
run: |
sudo apt-get install intel-oneapi-dpcpp-cpp-compiler
- name: Install Lua
if: ${{ !github.event.pull_request || github.event.action != 'closed' }}
run: |
sudo apt-get install liblua5.2-dev
- name: Install Doxygen
if: ${{ !github.event.pull_request || github.event.action != 'closed' }}
run: |
sudo apt-get install doxygen
- name: Install CMake
if: ${{ !github.event.pull_request || github.event.action != 'closed' }}
run: |
sudo apt-get install cmake
- name: Setup Python
if: ${{ !github.event.pull_request || github.event.action != 'closed' }}
uses: actions/setup-python@v2
with:
python-version: '3.8'
architecture: x64
- name: Install sphinx dependencies
if: ${{ !github.event.pull_request || github.event.action != 'closed' }}
shell: bash -l {0}
run: |
pip install numpy cython setuptools sphinx sphinx_rtd_theme pydot graphviz
Expand All @@ -46,12 +55,14 @@ jobs:
with:
fetch-depth: 0
- name: Build dpctl
if: ${{ !github.event.pull_request || github.event.action != 'closed' }}
shell: bash -l {0}
run: |
source /opt/intel/oneapi/setvars.sh
python setup.py develop
python -c "import dpctl; print(dpctl.__version__)"
- name: Build docs
if: ${{ !github.event.pull_request || github.event.action != 'closed' }}
shell: bash -l {0}
run: |
# Ensure that SYCL libraries are on LD_LIBRARY_PATH
Expand All @@ -69,6 +80,7 @@ jobs:
git clean -dfx
cd ..
- name: Publish docs
if: ${{ github.ref == 'refs/heads/master' }}
shell: bash -l {0}
run: |
git remote add tokened_docs https://IntelPython:${{ secrets.GITHUB_TOKEN }}@github.com/IntelPython/dpctl.git
Expand All @@ -80,6 +92,60 @@ jobs:
mv ~/docs/* .
git add .
git config --global user.name 'github-actions[doc-deploy-bot]'
git config --gloabl user.email 'github-actions[doc-deploy-bot]@users.noreply.github.com'
git config --global user.email 'github-actions[doc-deploy-bot]@users.noreply.github.com'
git commit -m "Latest docs."
git push tokened_docs gh-pages
- name: Publish pull-request docs
if: ${{ github.event.pull_request && github.event.action != 'closed' }}
env:
PR_NUM: ${{ github.event.number }}
shell: bash -l {0}
run: |
git remote add tokened_docs https://IntelPython:${{ secrets.GITHUB_TOKEN }}@github.com/IntelPython/dpctl.git
git fetch tokened_docs
git checkout --track tokened_docs/gh-pages
echo `pwd`
[ -d pulls/${PR_NUM} ] && git rm -rf pulls/${PR_NUM}
mkdir -p pulls/${PR_NUM}
cd pulls/${PR_NUM}
mv ~/docs/* .
git add .
git config --global user.name 'github-actions[doc-deploy-bot]'
git config --global user.email 'github-actions[doc-deploy-bot]@users.noreply.github.com'
git commit -m "Docs for pull request ${PR_NUM}"
git push tokened_docs gh-pages
- name: Unpublished pull-request docs
if: ${{ github.event.pull_request && github.event.action == 'closed' }}
env:
PR_NUM: ${{ github.event.number }}
shell: bash -l {0}
run: |
git remote add tokened_docs https://IntelPython:${{ secrets.GITHUB_TOKEN }}@github.com/IntelPython/dpctl.git
git fetch tokened_docs
git checkout --track tokened_docs/gh-pages
echo `pwd`
[ -d pulls/${PR_NUM} ] && git rm -rf pulls/${PR_NUM}
git config --global user.name 'github-actions[doc-deploy-bot]'
git config --global user.email 'github-actions[doc-deploy-bot]@users.noreply.github.com'
git commit -m "Removing docs for closed pull request ${PR_NUM}"
git push tokened_docs gh-pages
- name: Comment with URL to published pull-request docs
if: ${{ github.event.pull_request && github.event.action != 'closed' }}
env:
PR_NUM: ${{ github.event.number }}
uses: mshick/add-pr-comment@v1
with:
message: |
View rendered docs @ https://intelpython.github.io/dpctl/pulls/${{ env.PR_NUM }}/index.html
repo-token: ${{ secrets.GITHUB_TOKEN }}
repo-token-user-login: 'github-actions[bot]'
- name: Comment with URL about removal of PR docs
if: ${{ github.event.pull_request && github.event.action == 'closed' }}
env:
PR_NUM: ${{ github.event.number }}
uses: mshick/add-pr-comment@v1
with:
message: |
Deleted rendered PR docs from intelpython.github.com/dpctl, latest should be updated shortly. :crossed_fingers:
repo-token: ${{ secrets.GITHUB_TOKEN }}
repo-token-user-login: 'github-actions[bot]'