Update README.md #226
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: github pages | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
types: [opened, synchronize, reopened, closed] | |
jobs: | |
main: | |
if: ${{ !(github.event.pull_request && github.event.action == 'closed') }} | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash -el {0} | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Setup conda | |
uses: conda-incubator/setup-miniconda@v2 | |
with: | |
auto-update-conda: true | |
run-post: false | |
miniforge-variant: Mambaforge | |
miniforge-version: latest | |
environment-file: environment.yml | |
- name: Conda info | |
run: | | |
conda info | |
conda list | |
- name: Sphinx | |
run: | | |
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: 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/DPEP/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: GitHub Pages [PR 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/DPEP.git | |
git fetch tokened_docs | |
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 commit -m "Removing docs for closed pull request ${PR_NUM}" | |
git push tokened_docs gh-pages | |
- name: Comment PR [docs removed] | |
uses: mshick/add-pr-comment@v1 | |
with: | |
message: | | |
Documentation preview removed. | |
repo-token: ${{ secrets.GITHUB_TOKEN }} | |
repo-token-user-login: 'github-actions[bot]' | |
allow-repeats: true |