Deploy #130
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy | |
'on': | |
push: | |
branches: | |
- main | |
schedule: | |
# run 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@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 | |
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: Index tutorials | |
env: | |
ALGOLIA_ID: ${{ secrets.ALGOLIA_ID }} | |
ALGOLIA_KEY: ${{ secrets.ALGOLIA_KEY }} | |
ALGOLIA_INDEX: ${{ secrets.ALGOLIA_INDEX }} | |
# using --ignore, exclude .html files that aren't tutorials from indexing | |
# (jupyterbook produces some .html files to define Sphinx macros, placing them | |
# in the _static directory) | |
run: | | |
astropylibrarian index tutorial-site \ | |
public/tutorials \ | |
https://learn.astropy.org/tutorials |