8383 github_token : ${{ secrets.GITHUB_TOKEN }}
8484 publish_dir : ./public
8585
86+ pre_index :
87+ # this job effectively tests the indexing before the next job that
88+ # clears it (so that the site doesn't end up empty if the indexing fails)
89+ runs-on : ubuntu-latest
90+ needs : deploy
91+
92+ steps :
93+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
94+
95+ - name : Set up Python
96+ uses : actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
97+ with :
98+ python-version : 3.12
99+
100+ - name : Install Python dependencies
101+ run : |
102+ python -m pip install -U pip
103+ python -m pip install -r deployment/requirements.txt
104+
86105 - name : Pre-index tutorials
87106 id : preindex
88107 env :
@@ -94,9 +113,27 @@ jobs:
94113 public/tutorials \
95114 https://learn.astropy.org/tutorials
96115
116+ clear_index :
117+ # this job clears all records in the Algolia index to ensure new content appears on
118+ # the site
119+ runs-on : ubuntu-latest
120+ needs : pre_index
121+
122+ steps :
123+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
124+
125+ - name : Set up Python
126+ uses : actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
127+ with :
128+ python-version : 3.12
129+
130+ - name : Install Python dependencies
131+ run : |
132+ python -m pip install -U pip
133+ python -m pip install -r deployment/requirements.txt
134+
97135 - name : Clear Algolia index
98136 id : clearindex
99- if : steps.preindex.outcome == 'success'
100137 env :
101138 ALGOLIA_ID : ${{ secrets.ALGOLIA_ID }}
102139 ALGOLIA_KEY : ${{ secrets.ALGOLIA_KEY }}
@@ -107,8 +144,24 @@ jobs:
107144 --algolia-key "$ALGOLIA_KEY" \
108145 --index "$ALGOLIA_INDEX"
109146
147+ index :
148+ runs-on : ubuntu-latest
149+ needs : clear_index
150+
151+ steps :
152+ - uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
153+
154+ - name : Set up Python
155+ uses : actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
156+ with :
157+ python-version : 3.12
158+
159+ - name : Install Python dependencies
160+ run : |
161+ python -m pip install -U pip
162+ python -m pip install -r deployment/requirements.txt
163+
110164 - name : Index tutorials
111- if : steps.clearindex.outcome == 'success'
112165 env :
113166 ALGOLIA_ID : ${{ secrets.ALGOLIA_ID }}
114167 ALGOLIA_KEY : ${{ secrets.ALGOLIA_KEY }}
@@ -119,6 +172,8 @@ jobs:
119172 https://learn.astropy.org/tutorials
120173
121174 - name : Index guides
175+ # continue on error because guides can be externally hosted; avoid a change to
176+ # them from preventing the tutorials updating on the site
122177 continue-on-error : true
123178 env :
124179 ALGOLIA_ID : ${{ secrets.ALGOLIA_ID }}
0 commit comments