From 927e34b3b70911cc289b7ac082730242e0b6764b Mon Sep 17 00:00:00 2001 From: Yuki Kishimoto Date: Sat, 30 Sep 2023 15:49:59 +0200 Subject: [PATCH] ci: add book.yml --- .github/workflows/book.yml | 33 +++++++++++++++++++++++++++++++++ .gitmodules | 3 +++ book/.gitignore | 1 - book/Makefile | 14 ++++++++++++-- book/public | 1 + 5 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/book.yml create mode 100644 .gitmodules delete mode 100644 book/.gitignore create mode 160000 book/public diff --git a/.github/workflows/book.yml b/.github/workflows/book.yml new file mode 100644 index 000000000..85c65089d --- /dev/null +++ b/.github/workflows/book.yml @@ -0,0 +1,33 @@ +name: Build and deploy unstable book + +on: + push: + branches: + - master + paths: + - "book/**.md" + - "book/mkdocs.yml" + workflow_dispatch: + +jobs: + build: + name: Build and deploy + runs-on: ubuntu-latest + defaults: + run: + working-directory: book/ + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ssh-key: ${{ secrets.BOOK_DEPLOY_KEY }} + - name: Set up Python Virtualenv + uses: actions/setup-python@v4 + with: + python-version: 3.9 + - name: Install dependencies + run: make init + - name: Configure git + run: git config --global user.email "github-actions@github.com" && git config --global user.name "github-actions" + - name: Deploy unstable book + run: make deploy-unstable \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..a121a7d75 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "book/public"] + path = book/public + url = https://github.com/rust-nostr/rust-nostr.github.io.git diff --git a/book/.gitignore b/book/.gitignore deleted file mode 100644 index ccbfadbd8..000000000 --- a/book/.gitignore +++ /dev/null @@ -1 +0,0 @@ -site/ \ No newline at end of file diff --git a/book/Makefile b/book/Makefile index 07432de60..facec1d48 100644 --- a/book/Makefile +++ b/book/Makefile @@ -2,8 +2,18 @@ init: pip install -U poetry poetry install -build: - poetry run mkdocs build --strict --clean --verbose +checkout: + git submodule update --init --recursive --remote + +build: checkout + poetry run mkdocs build --strict --clean --verbose --site-dir public/book + +deploy: build + cd public && git add book && git commit -m "Deploy book" && git push origin HEAD:master --force + +deploy-unstable: checkout + poetry run mkdocs build --strict --clean --verbose --site-dir public/book-unstable + cd public && git add book-unstable && git commit -m "Deploy unstable book" && git push origin HEAD:master --force serve: mkdocs serve \ No newline at end of file diff --git a/book/public b/book/public new file mode 160000 index 000000000..9de3ac8f1 --- /dev/null +++ b/book/public @@ -0,0 +1 @@ +Subproject commit 9de3ac8f1f0405d3bdc547252caa76245373a68d