Skip to content

Commit

Permalink
update docs generation workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
tuunit committed Jan 13, 2024
1 parent 5190540 commit c236e3c
Showing 1 changed file with 30 additions and 34 deletions.
64 changes: 30 additions & 34 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,66 +7,62 @@ on:
push:
branches: [master]
paths: ['docs/**']
workflow_dispatch:

jobs:
pull-request-check:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Pages
id: pages
uses: actions/configure-pages@v4

- uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20
cache: npm
cache-dependency-path: "./docs/package-lock.json"

- name: Test Build
working-directory: ./docs
run: |
npm ci
npm run build
gh-pages-release:
if: github.event_name == 'push'
build-docs:
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
path: master

- uses: actions/checkout@v4
with:
ref: gh-pages
path: gh-pages

- uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20

- name: Build docusaurus
working-directory: master/docs
id: build
working-directory: ./docs
run: |
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
npm ci
npm run build
- name: Upload artifact
uses: actions/upload-pages-artifact@3
with:
path: ./docs/build

- name: Release to github pages
env:
GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }}
working-directory: gh-pages
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
# Remove all files except .git
git rm -r *
# Copy the build files from master/docs/build to gh-pages
cp -r ../master/docs/build/* .
# Commit and push
git add .
git commit -m "Update documentation based on ${{ steps.build.outputs.sha }}"
git push origin gh-pages
deploy-docs:
needs: build-docs
runs-on: ubuntu-latest
permissions:
contents: read
pages: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

0 comments on commit c236e3c

Please sign in to comment.