Skip to content

Instantly share code, notes, and snippets.

@apainintheneck
Created January 16, 2024 04:30
Show Gist options
  • Save apainintheneck/f7c27636c16e029d2d548a1fc371566f to your computer and use it in GitHub Desktop.
Save apainintheneck/f7c27636c16e029d2d548a1fc371566f to your computer and use it in GitHub Desktop.
Generate a documentation website on Github Pages for a Crystal project.
# This action does the following on a push to the `main` branch:
# 1. It generates the docs website with `crystal docs`.
# 2. It bundles that docs folder and pushes it to the `gh-pages` branch.
# 3. It deploys that branch to Github pages.
#
# First time setup:
# - Go into the Github settings and specify that the `gh-pages` branch
# should be deployed on Github pages.
name: Github Pages for Crystal Project
on:
push:
branches: main
permissions:
contents: write
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Install Crystal
uses: oprypin/install-crystal@v1
with:
crystal: latest
- name: Checkout branch
uses: actions/checkout@v3
- name: Install dependencies
run: shards install
- name: Generate docs
run: crystal docs
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/main'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment