From 9aec5a02574015ace7c5a569beef1634972c54b0 Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 12 Nov 2021 11:33:21 +0300 Subject: [PATCH 1/7] Add automation for publishing documentation to GitHub Pages --- .github/workflows/documentation.yml | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/documentation.yml diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml new file mode 100644 index 0000000..913d66a --- /dev/null +++ b/.github/workflows/documentation.yml @@ -0,0 +1,30 @@ +name: Documentation +on: + push: + branches: + - main + +jobs: + docs: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Sphinx + run: | + conda env create -f environment.yml + conda activate docs + cd docs + make html + + - name: GitHub Pages + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + destination_dir : main + publish_dir: docs/_build/html/ + allow_empty_commit : true + commit_message: ${{ github.event.head_commit.message }} From cfe7a0e06ffb5006bfdb7c58e11d8d4487ab4a2e Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 12 Nov 2021 12:31:39 +0300 Subject: [PATCH 2/7] Enable for PRs --- .github/workflows/documentation.yml | 30 ---------- .github/workflows/gh-pages.yml | 88 +++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 30 deletions(-) delete mode 100644 .github/workflows/documentation.yml create mode 100644 .github/workflows/gh-pages.yml diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml deleted file mode 100644 index 913d66a..0000000 --- a/.github/workflows/documentation.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Documentation -on: - push: - branches: - - main - -jobs: - docs: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Sphinx - run: | - conda env create -f environment.yml - conda activate docs - cd docs - make html - - - name: GitHub Pages - uses: peaceiris/actions-gh-pages@v3 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - destination_dir : main - publish_dir: docs/_build/html/ - allow_empty_commit : true - commit_message: ${{ github.event.head_commit.message }} diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml new file mode 100644 index 0000000..aa22ec8 --- /dev/null +++ b/.github/workflows/gh-pages.yml @@ -0,0 +1,88 @@ +name: GitHub Pages +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened, closed] + +jobs: + docs: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Sphinx + run: | + conda env create -f environment.yml + conda activate docs + cd docs + make html + + - name: GitHub Pages [main] + uses: peaceiris/actions-gh-pages@v3 + if: ${{ github.ref == 'refs/heads/main' }} + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./docs/_build/html/ + destination_dir: ./main + allow_empty_commit : true + commit_message: ${{ github.event.head_commit.message }} + publish_branch: gh-pages + user_name: 'github-actions[bot]' + user_email: 'github-actions[bot]@users.noreply.github.com' + + - name: GitHub Pages [PR] + uses: peaceiris/actions-gh-pages@v3 + if: ${{ github.event.pull_request && github.event.action != 'closed' }} + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./docs/_build/html/ + destination_dir: ./pull/${{ github.event.number }} + allow_empty_commit : true + commit_message: ${{ github.event.head_commit.message }} + publish_branch: gh-pages + user_name: 'github-actions[bot]' + user_email: 'github-actions[bot]@users.noreply.github.com' + + + - 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/DPPY.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 PR with URL to published 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/DPPY/pulls/${{ env.PR_NUM }}/index.html + repo-token: ${{ secrets.GITHUB_TOKEN }} + repo-token-user-login: 'github-actions[bot]' + + - name: Comment PR about removal 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 docs for the PR. + repo-token: ${{ secrets.GITHUB_TOKEN }} + repo-token-user-login: 'github-actions[bot]' From 54e56fcb30ae31ca814091534a4bf8d4af5cfb8c Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 12 Nov 2021 12:34:03 +0300 Subject: [PATCH 3/7] echo $CONDA/bin >> $GITHUB_PATH --- .github/workflows/gh-pages.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index aa22ec8..02ec8e0 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -15,6 +15,8 @@ jobs: with: fetch-depth: 0 + - run: echo $CONDA/bin >> $GITHUB_PATH + - name: Sphinx run: | conda env create -f environment.yml From e5e775ae373460a04769182e9e2b2280cfc194fd Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 12 Nov 2021 12:35:22 +0300 Subject: [PATCH 4/7] Use base conda env --- .github/workflows/gh-pages.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 02ec8e0..aa59a0f 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -19,8 +19,7 @@ jobs: - name: Sphinx run: | - conda env create -f environment.yml - conda activate docs + conda env update -f environment.yml --prune cd docs make html From 12fdc3076163a0443d85e53ca20d079f19ce1f36 Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 12 Nov 2021 12:38:14 +0300 Subject: [PATCH 5/7] Rename job --- .github/workflows/gh-pages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index aa59a0f..29b64b1 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -7,7 +7,7 @@ on: types: [opened, synchronize, reopened, closed] jobs: - docs: + main: runs-on: ubuntu-latest steps: From daafa6ebfcbac8610897b04da6a24adb357f347e Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 12 Nov 2021 12:47:46 +0300 Subject: [PATCH 6/7] Jobs configured --- .github/workflows/gh-pages.yml | 66 ++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 23 deletions(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 29b64b1..80c4dd4 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -8,6 +8,7 @@ on: jobs: main: + if: ${{ !(github.event.pull_request && github.event.action == 'closed') }} runs-on: ubuntu-latest steps: @@ -15,11 +16,24 @@ jobs: with: fetch-depth: 0 - - run: echo $CONDA/bin >> $GITHUB_PATH + - name: Add conda to system path + run: echo $CONDA/bin >> $GITHUB_PATH + + - name: Install documentation tools + run: | + which pip + pip install \ + sphinx \ + autodoc \ + recommonmark \ + sphinx-rtd-theme - name: Sphinx run: | - conda env update -f environment.yml --prune + # conda env update -f environment.yml --prune + which python + which sphinx-build + echo $PATH cd docs make html @@ -49,9 +63,28 @@ jobs: user_name: 'github-actions[bot]' user_email: 'github-actions[bot]@users.noreply.github.com' + - name: Comment PR [docs created] + if: ${{ github.event.pull_request && github.event.action != 'closed' }} + env: + PR_NUM: ${{ github.event.number }} + uses: mshick/add-pr-comment@v1 + with: + message: | + Documentation preview: [show](https://intelpython.github.io/DPPY/pull/${{ env.PR_NUM }}). + repo-token: ${{ secrets.GITHUB_TOKEN }} + repo-token-user-login: 'github-actions[bot]' + allow-repeats: true + + clean: + if: ${{ github.event.pull_request && github.event.action == 'closed' }} + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 - - name: Unpublished pull-request docs - if: ${{ github.event.pull_request && github.event.action == 'closed' }} + - name: GitHub Pages [PR closed] env: PR_NUM: ${{ github.event.number }} shell: bash -l {0} @@ -60,30 +93,17 @@ jobs: 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' + [ -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 commit -m "Removing docs for closed pull request ${PR_NUM}" git push tokened_docs gh-pages - - name: Comment PR with URL to published 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/DPPY/pulls/${{ env.PR_NUM }}/index.html - repo-token: ${{ secrets.GITHUB_TOKEN }} - repo-token-user-login: 'github-actions[bot]' - - - name: Comment PR about removal docs - if: ${{ github.event.pull_request && github.event.action == 'closed' }} - env: - PR_NUM: ${{ github.event.number }} + - name: Comment PR [docs removed] uses: mshick/add-pr-comment@v1 with: message: | - Deleted docs for the PR. + Documentation preview removed. repo-token: ${{ secrets.GITHUB_TOKEN }} repo-token-user-login: 'github-actions[bot]' + allow-repeats: true From 67fbb5c87e220c09501857f3385fe4b3bb2dc8af Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 12 Nov 2021 14:18:45 +0300 Subject: [PATCH 7/7] Use environment.yml --- .github/workflows/gh-pages.yml | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 80c4dd4..73701fb 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -19,21 +19,9 @@ jobs: - name: Add conda to system path run: echo $CONDA/bin >> $GITHUB_PATH - - name: Install documentation tools - run: | - which pip - pip install \ - sphinx \ - autodoc \ - recommonmark \ - sphinx-rtd-theme - - name: Sphinx run: | - # conda env update -f environment.yml --prune - which python - which sphinx-build - echo $PATH + conda env update -n base -f environment.yml --prune cd docs make html