-
Notifications
You must be signed in to change notification settings - Fork 7
106 lines (95 loc) · 3.42 KB
/
publish.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
name: Github Pages
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, edited, reopened]
branches:
- master
pull_request_target:
types: [closed]
branches:
- master
schedule:
- cron: '0 0 * * 1'
jobs:
deploy:
if: ${{ github.event.action != 'closed' }}
runs-on: ubuntu-latest
env:
PR_PATH: dipy.org/pull/${{github.event.number}}
BASE_URL: https://dipy.github.io/dipy.org
HEAD: ${{ github.event.pull_request.head.repo.full_name }}
BASE: ${{ github.repository }}
NB: ${{github.event.number}}
REF: ${{github.ref}}
STATUS: ${{github.event.pull_request.head.repo.full_name != github.repository}}
steps:
- name: Save the PR number in an artifact
if: ${{ github.event_name == 'pull_request' }}
shell: bash
env:
PULL_REQUEST_NUMBER: ${{ github.event.number }}
run: echo $PULL_REQUEST_NUMBER > pull_request_number.txt
- name: Upload the PULL REQUEST number
if: ${{ github.event_name == 'pull_request' }}
uses: actions/upload-artifact@v4
with:
name: pull_request_number
path: ./pull_request_number.txt
- name: Checkout website repo
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Build website
run: |
make -C . html
- name: Upload HTML
uses: actions/upload-artifact@v4
with:
name: DocumentationHTML
path: _build/html/
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
if: ${{ (github.event.pull_request.head.repo.full_name == '' || github.event.pull_request.head.repo.full_name == github.repository) && github.repository_owner == 'dipy'}}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./_build/html
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
commit_message: ${{ github.event.head_commit.message }}
# cname: ${{ env.DOMAIN # TODO: set this if you're using a custom domain.
on-closed:
runs-on: ubuntu-latest
if: ${{ github.event.action == 'closed' }}
env:
PR_PATH: dipy.org/pull/${{github.event.number}}
steps:
- name: make empty dir
run: mkdir public
- name: delete folder
uses: peaceiris/actions-gh-pages@v4
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_TOKEN }}
external_repository: dipy/preview-html
publish_dir: ./public
publish_branch: main
destination_dir: ${{ env.PR_PATH }}
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
commit_message: ${{ github.event.head_commit.message }}
- name: Update PR Comment
uses: hasura/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
number: ${{ github.event.number }}
id: deploy-preview
message: "🪓 PR closed, deleted preview at https://github.com/dipy/preview-html/tree/main/${{ env.PR_PATH }}/"