• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1name: Deploy
2
3on:
4  push:
5    branches:
6      - master
7    paths:
8      - book/**
9      - .github/workflows/site.yml
10  workflow_dispatch:
11
12jobs:
13  deploy:
14    name: Deploy
15    runs-on: ubuntu-latest
16    permissions:
17      contents: write
18    timeout-minutes: 30
19    steps:
20      - uses: actions/checkout@v3
21
22      - name: Get mdBook
23        run: |
24          export MDBOOK_VERSION="dtolnay"
25          export MDBOOK_TARBALL="mdbook-${MDBOOK_VERSION}-x86_64-unknown-linux-gnu.tar.gz"
26          export MDBOOK_URL="https://github.com/dtolnay/mdBook/releases/download/cxx/${MDBOOK_TARBALL}"
27          curl -Lf "${MDBOOK_URL}" | tar -xzC book
28          book/mdbook --version
29
30      - name: Build
31        run: book/build.sh
32
33      - name: Push to gh-pages
34        working-directory: book/build
35        run: |
36          REV=$(git rev-parse --short HEAD)
37          git init
38          git remote add upstream https://x-access-token:${{secrets.GITHUB_TOKEN}}@github.com/dtolnay/cxx
39          git config user.name "CXX"
40          git config user.email "dtolnay+cxx@gmail.com"
41          git add -A .
42          git commit -qm "Website @ ${{github.repository}}@${REV}"
43          git push -q upstream HEAD:refs/heads/gh-pages --force
44