11name : deploy-book
22
3- # Only run this when the main branch changes
43on :
54 push :
65 branches :
7- - main
6+ - main
7+ - ' *-translations'
8+ - ' !1.0-translations'
9+
10+ concurrency :
11+ group : " gh-pages"
12+ cancel-in-progress : true
813
9- # This job installs dependencies, build the book, and pushes it to `gh-pages`
1014jobs :
15+ get-info :
16+ runs-on : ubuntu-latest
17+ outputs :
18+ languages : ${{ steps.get-languages.outputs.languages }}
19+ version : ${{ steps.version-info.outputs.version }}
20+ steps :
21+ - name : Checkout repository
22+ uses : actions/checkout@v4
23+
24+ - name : Get languages directly with jq
25+ id : get-languages
26+ run : |
27+ languages=$(jq -c '[.[] | .code]' DISCOVER/_static/languages.json)
28+ echo "languages=${languages}" >> "$GITHUB_OUTPUT"
29+
30+ - name : Determine version from GitHub context
31+ id : version-info
32+ env :
33+ REF_NAME : ${{ github.ref_name }}
34+ REF_TYPE : ${{ github.ref_type }}
35+ run : |
36+ version="dev"
37+ if [[ "$REF_TYPE" == "tag" ]]; then
38+ version="${REF_NAME#v}"
39+ elif [[ "$REF_NAME" == *-translations ]]; then
40+ version="${REF_NAME%-translations}"
41+ fi
42+ echo "version=$version" >> "$GITHUB_OUTPUT"
43+
1144 deploy-book :
45+ needs : get-info
1246 runs-on : ubuntu-latest
47+ strategy :
48+ max-parallel : 1
49+ matrix :
50+ language : ${{ fromJSON(needs.get-info.outputs.languages) }}
1351 steps :
14- - uses : actions/checkout@v2
15-
16- - name : Set up Python 3.7
17- uses : actions/setup-python@v1
18- with :
19- python-version : 3.7
20-
21- - name : Install dependencies
22- run : |
23- pip install jupyter-book
24- pip install sphinx-tags
25-
26- - name : Build the book
27- run : |
28- rm -rf DISCOVER/_tags/*
29- jupyter-book build DISCOVER
30-
31- - name : Push book HTML to gh-pages
32- 33- with :
34- github_token : ${{ secrets.GITHUB_TOKEN }}
35- publish_dir : ./DISCOVER/_build/html
36- keep_files : true
52+ - name : Checkout repository
53+ uses : actions/checkout@v4
54+ with :
55+ fetch-depth : 0
56+
57+ - name : Set up Python 3.13
58+ uses : actions/setup-python@v5
59+ with :
60+ python-version : ' 3.13'
61+
62+ - name : Build documentation with script
63+ env :
64+ VERSION : ${{ needs.get-info.outputs.version }}
65+ LANGUAGE : ${{ matrix.language }}
66+ run : |
67+ bash ci/build_website.sh
68+
69+ - name : Deploy language to GitHub Pages
70+ uses : peaceiris/actions-gh-pages@v4
71+ with :
72+ github_token : ${{ secrets.GITHUB_TOKEN }}
73+ publish_dir : ./DISCOVER/_build/html
74+ destination_dir : ${{ needs.get-info.outputs.version }}/${{ matrix.language }}
75+ keep_files : true
76+
77+ create-redirect :
78+ needs : [get-info, deploy-book]
79+ runs-on : ubuntu-latest
80+ steps :
81+ - name : Create version redirect
82+ run : |
83+ mkdir -p temp_redirect
84+ cat > temp_redirect/index.html << 'EOF'
85+ <!DOCTYPE html>
86+ <html>
87+ <head>
88+ <meta charset="UTF-8">
89+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
90+ <title>DISCOVER Cookbook - Redirecting...</title>
91+ <link rel="canonical" href="./en/">
92+ <meta http-equiv="refresh" content="0; url=./en/">
93+ </head>
94+ <body>
95+ <a href="./en/">Redirecting to English...</a>
96+ </body>
97+ </html>
98+ EOF
99+
100+ - name : Deploy version redirect
101+ uses : peaceiris/actions-gh-pages@v4
102+ with :
103+ github_token : ${{ secrets.GITHUB_TOKEN }}
104+ publish_dir : ./temp_redirect
105+ destination_dir : ${{ needs.get-info.outputs.version }}
106+ keep_files : true
107+
108+ deploy-root-files :
109+ needs : [create-redirect]
110+ runs-on : ubuntu-latest
111+ if : github.ref_name == 'main'
112+ steps :
113+ - name : Checkout repository
114+ uses : actions/checkout@v4
115+
116+ - name : Create root files directory
117+ run : |
118+ mkdir -p root_files
119+ cp DISCOVER/404.html root_files/
120+ cp index.html root_files/
121+ cp DISCOVER/_static/versions.json root_files/
122+
123+ - name : Deploy root files to GitHub Pages
124+ uses : peaceiris/actions-gh-pages@v4
125+ with :
126+ github_token : ${{ secrets.GITHUB_TOKEN }}
127+ publish_dir : ./root_files
128+ destination_dir : .
129+ keep_files : true
0 commit comments