Add flag to skip directory creation if it exists #43
This file contains 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: Build and deploy site | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
name: Build site with Jekyll and JupyterLite | |
steps: | |
# Check out from Git | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
# Set up and use cache for Python dependencies | |
- name: Python dependencies cache | |
id: python-dependencies-cache | |
uses: actions/cache@v4 | |
with: | |
# cache downloaded and installed packages | |
path: | | |
~/.cache/pip | |
~/.local/lib/python3.11/site-packages | |
~/.local/bin | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
# Install Jupyter and any other Python packages defined in requirements.txt | |
- name: Install Python dependencies | |
working-directory: jupyterlite | |
run: | | |
python -m pip install --user --upgrade pip | |
python -m pip install --user -r requirements.txt | |
# Set up and use cache for Jekyll page generation | |
- name: Jekyll rendered pages cache | |
id: jekyll-build-cache | |
uses: actions/cache@v4 | |
with: | |
# cache generated pages and assets | |
path: | | |
_site | |
key: jekyll-${{ hashFiles('public/**') }} | |
restore-keys: | | |
jekyll- | |
# Build the main part of the site using Jekyll Docker image | |
- name: Build the main site with Jekyll | |
if: steps.jekyll-build-cache.outputs.cache-hit != 'true' | |
working-directory: public | |
run: | | |
docker run \ | |
-v ${{ github.workspace }}/public:/srv/jekyll -v ${{ github.workspace }}/_site:/srv/jekyll/_site \ | |
-e PAGES_REPO_NWO=$GITHUB_REPOSITORY -e JEKYLL_GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} \ | |
jekyll/builder:pages /bin/bash -c \ | |
"chmod -R 777 /srv/jekyll && jekyll build --incremental --future" | |
# Build the lab part of the site using JupyterLab | |
- name: Build the lab site with JupyterLite | |
working-directory: jupyterlite | |
run: | | |
mkdir -p ../_site/notebooks/ | |
jupyter lite build --contents notebooks --output-dir ../_site/notebooks | |
# Ready and upload artifact for deployment | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v3 | |
deploy: | |
needs: build | |
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment | |
permissions: | |
pages: write # to deploy to Pages | |
id-token: write # to verify the deployment originates from an appropriate source | |
# Deploy to the github-pages environment | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
# Specify runner + deployment step | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 # or specific "vX.X.X" version tag for this action |