Skip to content

Commit

Permalink
fix: add action to deploy docs on change (#4)
Browse files Browse the repository at this point in the history
* fix: add action to deploy docs on change

Signed-off-by: Moritz Johner <[email protected]>
  • Loading branch information
moritzjohner-form3 authored Dec 13, 2024
1 parent 86a7275 commit d3d913b
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 34 deletions.
21 changes: 15 additions & 6 deletions .github/actions/mkdocs/action.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,29 @@ fi
git config --global user.name "$GITHUB_ACTOR"
git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com"

mkdocs build --config-file "${GITHUB_WORKSPACE}/docs/mkdocs.yml"
docs_site_tmp_dir=$(mktemp -d)
cd docs && mkdocs build --config-file "${GITHUB_WORKSPACE}/docs/mkdocs.yml" -d "${docs_site_tmp_dir}"

git clone --branch=gh-pages --depth=1 "${remote_repo}" gh-pages
cd gh-pages
gh_pages_tmp_dir=$(mktemp -d)

cd $gh_pages_tmp_dir
git clone --branch=gh-pages --depth=1 "${remote_repo}" .

# copy current index file index.yaml before any change
temp_worktree=$(mktemp -d)
cp --force "index.yaml" "$temp_worktree/index.yaml"
if [ -f "index.yaml" ]; then
cp --force "index.yaml" "$temp_worktree/index.yaml"
fi
# remove current content in branch gh-pages
git rm -r .
# copy new doc.
cp -r ../site/* .
cp -r "${docs_site_tmp_dir}"/* .

# restore chart index
cp "$temp_worktree/index.yaml" .
if [ -f "index.yaml" ]; then
cp "$temp_worktree/index.yaml" .
fi

# commit changes
git add .
git commit -m "Deploy GitHub Pages"
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Documentation

on:
push:
branches:
- main
- mj-deploy-docs

permissions:
contents: read

jobs:

changes:
permissions:
contents: read # for dorny/paths-filter to fetch a list of changed files
pull-requests: read # for dorny/paths-filter to read pull requests
runs-on: ubuntu-latest
outputs:
docs: ${{ steps.filter.outputs.docs }}
charts: ${{ steps.filter.outputs.charts }}

steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: filter
with:
token: ${{ secrets.GITHUB_TOKEN }}
filters: |
docs:
- 'docs/**/*'
docs:
name: Update
runs-on: ubuntu-latest
needs:
- changes
if: needs.changes.outputs.docs == 'true'

permissions:
contents: write # needed to write releases

steps:
- name: Checkout master
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Deploy
uses: ./.github/actions/mkdocs
env:
PERSONAL_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
16 changes: 0 additions & 16 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
.PHONY: check_dead_links
check_dead_links: ## Check if the documentation contains dead links.
@docker run -t \
-w /tmp \
-v $$PWD:/tmp dkhamsing/awesome_bot:1.20.0 \
--allow-dupe \
--allow-redirect $(shell find $$PWD -mindepth 1 -name vendor -prune -o -name .modcache -prune -o -iname Changelog.md -prune -o -name "*.md" | sed -e "s#$$PWD/##")

.PHONY: build-image
build-image:
@docker build \
Expand All @@ -29,11 +21,3 @@ live-docs: build-image ## Build and launch a local copy of the documentation web
--entrypoint /bin/bash \
xpdb-docs \
-c "pip install -r /docs/requirements.txt && mkdocs serve --dev-addr=0.0.0.0:8000"

.PHONY: misspell
misspell: ## Check for spelling errors.
@go install github.com/client9/misspell/cmd/misspell@latest
misspell \
-locale US \
-error \
.
9 changes: 0 additions & 9 deletions docs/extra.css

This file was deleted.

4 changes: 1 addition & 3 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ repo_name: "form3tech-oss/x-pdb"
repo_url: https://github.com/form3tech-oss/x-pdb
site_url: https://form3tech-oss.github.io/x-pdb
edit_uri: edit/main/docs/src
docs_dir: "/docs/src"
docs_dir: "src"

# Extensions
markdown_extensions:
Expand Down Expand Up @@ -63,8 +63,6 @@ plugins:
- minify:
minify_html: true

extra_css: [extra.css]

nav:
- Introduction:
- Overview: "index.md"
Expand Down

0 comments on commit d3d913b

Please sign in to comment.