Skip to content

Merge pull request #100 from astropy/dependabot/npm_and_yarn/cross-sp… #70

Merge pull request #100 from astropy/dependabot/npm_and_yarn/cross-sp…

Merge pull request #100 from astropy/dependabot/npm_and_yarn/cross-sp… #70

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@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@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: ${{ steps.node_version.outputs.NODE_VERSION }}
- name: Cache dependencies
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
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@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0
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@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.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