-
Notifications
You must be signed in to change notification settings - Fork 14
172 lines (143 loc) · 5.13 KB
/
deploy.yaml
File metadata and controls
172 lines (143 loc) · 5.13 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
name: Deploy
'on':
push:
branches:
- main
schedule:
# weekly on Sunday
- cron: "20 10 * * 0"
# allow manual triggering of workflow
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Read .nvmrc
id: node_version
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)
- name: Set up node
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: ${{ steps.node_version.outputs.NODE_VERSION }}
- name: Cache dependencies
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ steps.node_version.outputs.NODE_VERSION }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-${{ steps.node_version.outputs.NODE_VERSION }}
- run: npm ci
name: Install
- run: npm run build
name: Build
- name: Upload gatsby artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: gatsby-build
path: ./public
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install Python dependencies
run: |
python -m pip install -U pip
python -m pip install -r deployment/requirements.txt
- name: Download gatsby artifact
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: gatsby-build
path: ./public
- name: Install tutorials into site
run: |
python deployment/installtutorials.py --dest public/tutorials
- name: List website content
run: |
tree public
- name: Deploy to gh-pages
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
- name: Upload site for indexing
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: site-for-indexing
path: ./public
index:
# this job effectively tests the indexing before the next job that
# clears it (so that the site doesn't end up empty if the indexing fails)
runs-on: ubuntu-latest
needs: deploy
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Download site for indexing
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: site-for-indexing
path: ./public
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install Python dependencies
run: |
python -m pip install -U pip
python -m pip install -r deployment/requirements.txt
- name: Pre-index tutorials
id: preindex
env:
ALGOLIA_ID: ${{ secrets.ALGOLIA_ID }}
ALGOLIA_KEY: ${{ secrets.ALGOLIA_KEY }}
ALGOLIA_INDEX: ${{ secrets.ALGOLIA_INDEX }}
run: |
astropylibrarian index tutorial-site \
public/tutorials \
https://learn.astropy.org/tutorials
- name: sleep
run: sleep 5
- name: Clear Algolia index
id: clearindex
if: steps.preindex.outcome == 'success'
env:
ALGOLIA_ID: ${{ secrets.ALGOLIA_ID }}
ALGOLIA_KEY: ${{ secrets.ALGOLIA_KEY }}
ALGOLIA_INDEX: ${{ secrets.ALGOLIA_INDEX }}
run: |
astropylibrarian clear-index \
--algolia-id "$ALGOLIA_ID" \
--algolia-key "$ALGOLIA_KEY" \
--index "$ALGOLIA_INDEX"
- name: sleep
run: sleep 5
- name: Index tutorials
if: steps.clearindex.outcome == 'success'
env:
ALGOLIA_ID: ${{ secrets.ALGOLIA_ID }}
ALGOLIA_KEY: ${{ secrets.ALGOLIA_KEY }}
ALGOLIA_INDEX: ${{ secrets.ALGOLIA_INDEX }}
run: |
astropylibrarian index tutorial-site \
public/tutorials \
https://learn.astropy.org/tutorials
- name: Index guides
# continue on error because guides can be externally hosted; avoid a change to
# them from preventing the tutorials updating on the site
continue-on-error: true
env:
ALGOLIA_ID: ${{ secrets.ALGOLIA_ID }}
ALGOLIA_KEY: ${{ secrets.ALGOLIA_KEY }}
ALGOLIA_INDEX: ${{ secrets.ALGOLIA_INDEX }}
run: |
astropylibrarian index guide \
http://www.astropy.org/ccd-reduction-and-photometry-guide/ \
--algolia-id "$ALGOLIA_ID" \
--algolia-key "$ALGOLIA_KEY" \
--index "$ALGOLIA_INDEX" \
--priority 2