-
Notifications
You must be signed in to change notification settings - Fork 7
114 lines (100 loc) · 3.56 KB
/
gh-pages.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
name: github pages
# Declare default permissions as read only.
permissions: read-all
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