|
| 1 | +name: Build and deploy website |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - main |
| 6 | + pull_request: |
| 7 | + branches: |
| 8 | + - main |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v4 |
| 16 | + # Adds keys to work with other repositories used in this lesson (e.g., UCL/github-example) |
| 17 | + # - uses: webfactory/ssh-agent@v0.9.0 |
| 18 | + # with: |
| 19 | + # ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} |
| 20 | + - uses: actions/cache@v4 # FIXME: add apt(latex) |
| 21 | + with: |
| 22 | + path: vendor/bundle |
| 23 | + key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile') }} |
| 24 | + restore-keys: | |
| 25 | + ${{ runner.os }}-gems- |
| 26 | + - uses: actions/cache@v4 |
| 27 | + with: |
| 28 | + path: ~/.cache/pip |
| 29 | + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt', '.github/python/requirements.txt') }} |
| 30 | + restore-keys: | |
| 31 | + ${{ runner.os }}-pip- |
| 32 | + - name: Install TeXLive |
| 33 | + uses: DanySK/setup-texlive-action@0.1.1 |
| 34 | + - id: setup-python |
| 35 | + name: Setup Python |
| 36 | + uses: actions/setup-python@v5 |
| 37 | + with: |
| 38 | + python-version: 3.12 |
| 39 | + - name: Install dependencies |
| 40 | + run: | |
| 41 | + sudo apt-get update |
| 42 | + sudo apt-get install python3-pydot graphviz |
| 43 | + python -m pip install -r .github/python/requirements.txt |
| 44 | + - name: Building notes |
| 45 | + run: make ready |
| 46 | + - uses: ruby/setup-ruby@v1 |
| 47 | + with: |
| 48 | + ruby-version: '3.3' |
| 49 | + - name: Install bundler and dependencies |
| 50 | + run: | |
| 51 | + gem install bundler |
| 52 | + bundle install |
| 53 | + - name: Build website |
| 54 | + run: bundle exec jekyll build |
| 55 | + - name: Build the JupyterLite site |
| 56 | + run: | |
| 57 | + find . -type d -name .pytest_cache -o -name .ruff_cache -o -name .doctrees | xargs rm -rf |
| 58 | + mkdir contents |
| 59 | + mkdir _site/jupyter-lite |
| 60 | + find ch*/ -type f -name '*.ipynb' ! -name '*.nbconvert.ipynb' -exec rsync -R {} contents/ \; |
| 61 | + jupyter lite build --contents contents --output-dir _site/jupyter-lite |
| 62 | + - name: Upload artifact |
| 63 | + uses: actions/upload-pages-artifact@v3 |
| 64 | + with: |
| 65 | + path: _site |
| 66 | + |
| 67 | + deploy: |
| 68 | + if: > |
| 69 | + github.ref == 'refs/heads/main' |
| 70 | + && github.repository == 'UCL/rsd-engineeringcourse' |
| 71 | + needs: build |
| 72 | + permissions: |
| 73 | + pages: write |
| 74 | + id-token: write |
| 75 | + environment: |
| 76 | + name: github-pages |
| 77 | + url: ${{ steps.deployment.outputs.page_url }} |
| 78 | + runs-on: ubuntu-latest |
| 79 | + steps: |
| 80 | + - name: Deploy to GitHub Pages |
| 81 | + id: deployment |
| 82 | + uses: actions/deploy-pages@v4 |
0 commit comments