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: Deploy mdBooks to GitHub Pages | |
on: | |
push: | |
branches: | |
- dev | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
- uses: taiki-e/install-action@mdbook | |
- name: Build mdbook | |
run: | | |
for book in aptos ethereum kadena; do | |
echo "Creating ${book} mdbook" | |
mkdir -p public/${book} | |
cd ${book}/docs | |
mdbook build | |
cp -r book/* ${{ github.workspace }}/public/${book} | |
cd ${{ github.workspace }} | |
done | |
- name: Upload build artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: ./public | |
retention-days: 1 | |
deploy: | |
needs: build | |
if: github.ref_name == 'dev' && github.event_name == 'push' | |
permissions: | |
pages: write | |
id-token: write | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 | |
# Detect changes in each subcrate | |
# changes: | |
# runs-on: ubuntu-latest | |
# outputs: | |
# # List of changed mdbooks | |
# books: ${{ steps.get-packages.outputs.books }} | |
# steps: | |
# - uses: actions/checkout@v4 | |
# - uses: dorny/paths-filter@v3 | |
# id: filter | |
# with: | |
# filters: | | |
# aptos: | |
# - 'aptos/docs/**' | |
# ethereum: | |
# - 'ethereum/docs/**' | |
# kadena: | |
# - 'kadena/docs/**' | |
# - name: Get list of changed packages | |
# id: get-packages | |
# run: | | |
# BOOKS=$(echo '${{ steps.filter.outputs.changes }}' | jq -c '.') | |
# echo "books=$BOOKS" | tee -a "$GITHUB_OUTPUT" | |
# | |
# # TODO: Build all light clients always unless we can only deploy changed and keep old | |
# build: | |
# needs: changes | |
# #if: ${{ needs.changes.outputs.books != '[]' && needs.changes.outputs.books != '' }} | |
# runs-on: ubuntu-latest | |
# strategy: | |
# fail-fast: false | |
# matrix: | |
# # Parse JSON array containing names of all changed light client mdbooks, | |
# # e.g. ['aptos', 'ethereum', 'kadena'] if the `aptos`, `ethereum` and `kadena` mdbooks contain changes. | |
# #light-client: ${{ fromJSON(needs.changes.outputs.books) }} | |
# light-client: ['aptos', 'ethereum', 'kadena'] | |
# steps: | |
# - uses: actions/checkout@v4 | |
# - uses: dtolnay/rust-toolchain@stable | |
# - uses: taiki-e/install-action@mdbook | |
# - run: | | |
# mdbook build | |
# ls book | |
# working-directory: ${{ github.workspace }}/${{ matrix.light-client }}/docs | |
# - name: Upload build artifact | |
# uses: actions/upload-artifact@v4 | |
# with: | |
# name: ${{ matrix.light-client }} | |
# path: ${{ matrix.light-client }}/docs/book | |
# retention-days: 1 | |
# | |
# deploy: | |
# needs: [changes, build] | |
# if: ${{ github.ref_name == 'dev' && github.event_name == 'push' }} | |
# runs-on: ubuntu-latest | |
# permissions: | |
# contents: write | |
# steps: | |
# - uses: actions/checkout@v4 | |
# - name: Create publish dir | |
# run: | | |
# mkdir -p public | |
# ls public | |
# working-directory: ${{ github.workspace }} | |
# - name: Download book artifacts | |
# uses: actions/download-artifact@v4 | |
# with: | |
# path: ./public | |
# - run: | | |
# echo "PUBLIC" | |
# ls public | |
# echo "PUBLIC/APTOS" | |
# ls public/aptos | |
# echo "PUBLIC/ETHEREUM" | |
# ls public/ethereum | |
# echo "PUBLIC/KADENA" | |
# ls public/kadena | |
# - name: Deploy mdbook | |
# uses: peaceiris/actions-gh-pages@v4 | |
# with: | |
# github_token: ${{ secrets.GITHUB_TOKEN }} | |
# publish_dir: ./public | |
# |