Skip to content

tutorials-build

tutorials-build #65

Workflow file for this run

name: Deploy
'on':
push:
branches:
- main
repository_dispatch:
types:
- 'tutorials-build' # triggered from astropy/astropy-tutorials
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Read .nvmrc
id: node_version
run: echo ::set-output name=NODE_VERSION::$(cat .nvmrc)
- name: Set up node
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
with:
node-version: ${{ steps.node_version.outputs.NODE_VERSION }}
- name: Cache dependencies
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
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@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0
with:
name: gatsby-build
path: ./public
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Set up Python
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5.2.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@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
name: gatsby-build
path: ./public
- name: Download tutorials for tutorial dispatch event
if: ${{ github.event == 'repository_dispatch' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python deployment/installtutorials.py \
--dest public/tutorials \
--tutorials-run ${{ github.event.client_payload.runid }} \
--tutorials-artifact ${{ github.event.client_payload.artifactName }} \
--tutorials-repo ${{ github.event.client_payload.repo }}
- name: Download latest tutorials
if: ${{ github.event != 'repository_dispatch' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python deployment/installtutorials.py --dest public/tutorials
- 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 }}
run: |
astropylibrarian index tutorial-site \
public/tutorials \
https://learn.astropy.org/tutorials