Skip to content

Commit

Permalink
Update website workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielleHuisman committed Oct 5, 2024
1 parent 516d775 commit 45a6334
Showing 1 changed file with 44 additions and 28 deletions.
72 changes: 44 additions & 28 deletions .github/workflows/book.yml → .github/workflows/website.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Book
name: Website
on:
pull_request: {}
push:
Expand All @@ -10,8 +10,8 @@ concurrency:
cancel-in-progress: false

jobs:
test:
name: Test
book-test:
name: Test Book
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -27,13 +27,11 @@ jobs:
cache-on-failure: true
save-if: ${{ github.ref == 'refs/heads/main' }}

- name: Install latest mdbook
run: |
tag=$(curl 'https://api.github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name')
url="https://github.com/rust-lang/mdbook/releases/download/${tag}/mdbook-${tag}-x86_64-unknown-linux-gnu.tar.gz"
mkdir bin
curl -sSL $url | tar -xz --directory=bin
echo "$(pwd)/bin" >> $GITHUB_PATH
- name: Install Cargo Binary Install
uses: cargo-bins/cargo-binstall@main

- name: Install mdBook
run: cargo binstall -y mdbook

- name: Install mdBook plugins
run: cargo install mdbook-tabs mdbook-trunk
Expand All @@ -42,15 +40,10 @@ jobs:
run: mdbook test
working-directory: book

deploy:
name: Deploy
needs: test
if: github.ref == 'refs/heads/main'
book-build:
name: Build Book
needs: book-test
runs-on: ubuntu-latest
permissions:
contents: read
pages: write
id-token: write
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -67,16 +60,11 @@ jobs:
cache-on-failure: true
save-if: ${{ github.ref == 'refs/heads/main' }}

- name: Install Trunk
run: cargo install trunk
- name: Install Cargo Binary Install
uses: cargo-bins/cargo-binstall@main

- name: Install latest mdbook
run: |
tag=$(curl 'https://api.github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name')
url="https://github.com/rust-lang/mdbook/releases/download/${tag}/mdbook-${tag}-x86_64-unknown-linux-gnu.tar.gz"
mkdir mdbook
curl -sSL $url | tar -xz --directory=./mdbook
echo `pwd`/mdbook >> $GITHUB_PATH
- name: Install mdBook and Trunk
run: cargo binstall -y mdbook trunk

- name: Install mdBook plugins
run: cargo install mdbook-tabs mdbook-trunk
Expand All @@ -92,13 +80,41 @@ jobs:
run: mdbook-trunk combine
working-directory: book

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: book
path: book/dist
retention-days: 1
if-no-files-found: error

deploy:
name: Deploy
needs: book-build
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: read
pages: write
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Download artifcats
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true

- name: Setup Pages
uses: actions/configure-pages@v4

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: 'book/dist'
path: dist

- name: Deploy to GitHub Pages
id: deployment
Expand Down

0 comments on commit 45a6334

Please sign in to comment.