forked from StingraySoftware/notebooks
-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (64 loc) · 2.34 KB
/
build_test_notebooks.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
name: Build & Test Notebooks
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
jobs:
build-notebooks:
runs-on: ubuntu-latest
steps:
- name: Checkout stingray repo
uses: actions/checkout@v4
with:
repository: StingraySoftware/stingray
path: ./stingray
submodules: recursive
# This step gets the latest commit of the PR or the pushed commit and checks out the PR version of the notebooks
- name: Get latest commit of the PR or pushed commit and Checkout PR version of Notebooks
run: |
# If the event is a pull request, fetch the PR SHA
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "PR event detected. Fetching PR SHA..."
PR_SHA=$(curl -s 'https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}' | jq -r .head.sha)
if [ "$PR_SHA" == "null" ]; then
echo "::error::Failed to get PR SHA"
exit 1
fi
echo "commit=$PR_SHA" >> $GITHUB_ENV
cd ./stingray/docs/notebooks # Change to the submodule directory
git fetch origin $PR_SHA:pr_temp
git checkout pr_temp
# If the event is a push, use the pushed commit SHA
else
echo "Push event detected. Using pushed commit SHA..."
echo "commit=${{ github.sha }}" >> $GITHUB_ENV
cd ./stingray/docs/notebooks # Change to the submodule directory
pwd
git fetch origin ${{ github.sha }}:pr_temp
git checkout pr_temp
fi
# This step verifies that the submodule has been updated
- name: Verify submodule update
run: |
cd ./stingray/docs/notebooks
git log -1
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install pandoc and additional dependencies
run: |
sudo apt-get update
sudo apt-get install -y pandoc fonts-freefont-ttf
pip install sphinx sphinx-astropy tox
- name: Install Stingray
run: |
pip install -e ./stingray
- name: Run Build Docs
run: |
cd ./stingray
tox -e build_docs