Skip to content

Commit

Permalink
use github action from oranda docs and configure site prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
untitaker committed Jun 25, 2023
1 parent 4353e88 commit a5254d7
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 45 deletions.
122 changes: 77 additions & 45 deletions .github/workflows/page.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,86 @@
# Sample workflow for building and deploying a Jekyll site to GitHub Pages
name: Deploy website
# https://opensource.axo.dev/oranda/book/hosting.html
#
# Workflow to build your docs with oranda (and mdbook)
# and deploy them to Github Pages
name: Web deploy

on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
# We're going to push to the gh-pages branch, so we need that permission
permissions:
contents: read
pages: write
id-token: write
contents: write

# Allow one concurrent deployment
concurrency:
group: "pages"
cancel-in-progress: true
# What situations do we want to build docs in?
# All of these work independently and can be removed / commented out
# if you don't want oranda/mdbook running in that situation
on:
# Check that a PR didn't break docs!
#
# Note that the "Deploy to Github Pages" step won't run in this mode,
# so this won't have any side-effects. But it will tell you if a PR
# completely broke oranda/mdbook. Sadly we don't provide previews (yet)!
pull_request:

# Whenever something gets pushed to main, update the docs!
# This is great for getting docs changes live without cutting a full release.
#
# Note that if you're using cargo-dist, this will "race" the Release workflow
# that actually builds the Github Release that oranda tries to read (and
# this will almost certainly complete first). As a result you will publish
# docs for the latest commit but the oranda landing page won't know about
# the latest release. The workflow_run trigger below will properly wait for
# cargo-dist, and so this half-published state will only last for ~10 minutes.
#
# If you only want docs to update with releases, disable this one.
push:
branches:
- main

# Whenever a workflow called "Release" completes, update the docs!
#
# If you're using cargo-dist, this is recommended, as it will ensure that
# oranda always sees the latest release right when it's available. Note
# however that Github's UI is wonky when you use workflow_run, and won't
# show this workflow as part of any commit. You have to go to the "actions"
# tab for your repo to see this one running (the gh-pages deploy will also
# only show up there).
workflow_run:
workflows: ["Release"]
types:
- completed

# Alright, let's do it!
jobs:
# Build job
build:
web:
name: Build and deploy site and docs
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Pages
uses: actions/configure-pages@v1
- name: Install Oranda
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/oranda/releases/download/v0.0.3/oranda-installer.sh | sh
- name: Install cargo-dist
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/cargo-dist/releases/download/v0.0.7/cargo-dist-installer.sh | sh
- name: Run oranda
run: oranda build
- run: find public/
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
# Setup
- uses: actions/checkout@v3
with:
path: ./public/
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
- uses: swatinem/rust-cache@v2

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
# Install and run oranda (and mdbook)
# This will write all output to ./public/ (including copying mdbook's output to there)
- name: Install and run oranda
run: |
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/oranda/releases/download/v0.1.0-prerelease.5/oranda-installer.sh | sh
oranda build
# Deploy to our gh-pages branch (making it if it doesn't exist)
# the "public" dir that oranda made above will become the root dir
# of this branch.
#
# Note that once the gh-pages branch exists, you must
# go into repo's settings > pages and set "deploy from branch: gh-pages"
# the other defaults work fine.
- name: Deploy to Github Pages
uses: JamesIves/github-pages-deploy-action@v4.4.1
# ONLY if we're on main (so no PRs or feature branches allowed!)
if: ${{ github.ref == 'refs/heads/main' }}
with:
branch: gh-pages
# Gotta tell the action where to find oranda's output
folder: public
token: ${{ secrets.GITHUB_TOKEN }}
single-commit: true
3 changes: 3 additions & 0 deletions oranda.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"artifacts": {
"cargo_dist": true
},
"build": {
"path_prefix": "spacemod"
}
}

0 comments on commit a5254d7

Please sign in to comment.