ci(action-pages): setup GitHub Pages action

pull/536/head
sabertazimi 4 years ago
parent 42c87ef3db
commit ac451eab06
No known key found for this signature in database
GPG Key ID: 6A07DD4DEAA65D8F

@ -0,0 +1,58 @@
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
CARGO_TERM_COLOR: always
jobs:
pages:
name: Building and Deployment
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: true
fetch-depth: 1
- name: Cache cargo binaries and registry
uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/book.toml') }}
- name: Install mdbook
continue-on-error: true
run: |
cargo install mdbook || exit 0
- name: Check toolchain version
run: |
rustc -V
cargo -V
mdbook -V
- name: Build book
run: |
mdbook build
- name: Copy metadata files
run: |
cp ./assets/CNAME ./book/
cp ./assets/*.html ./book/
cp ./assets/sitemap.xml ./book/
- name: Deploy to Github Pages
uses: peaceiris/actions-gh-pages@v3
if: ${{ github.ref == 'refs/heads/main' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./book
force_orphan: true
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
commit_message: ${{ github.event.head_commit.message }}

@ -1,21 +0,0 @@
## this script deploys the static website of course.rs to github pages
## build static website for book
mdbook build
## copy CNAME info to book dir
cp ./assets/CNAME ./book/
cp ./assets/*.html ./book/
cp ./assets/sitemap.xml ./book/
## init git repo
cd book
git init
git config user.name "sunface"
git config user.email "cto@188.com"
git add .
git commit -m 'deploy'
git branch -M gh-pages
git remote add origin https://github.com/sunface/rust-course
## push to github pages
git push -u -f origin gh-pages
Loading…
Cancel
Save