Skip to content

Commit

Permalink
Create a publish-docs workflow and rely on release branch
Browse files Browse the repository at this point in the history
This creates docs from master/release branches in the ci workflow which
is used as as sources for the unstable/stable versions of the docs. The
publish-docs workflow will then just aggregate the two versions and
pushes it to github pages.
  • Loading branch information
ffakenz authored and ch1bo committed Mar 31, 2023
1 parent 811f124 commit d050f28
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 14 deletions.
45 changes: 31 additions & 14 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
push:
branches:
- master
- release
pull_request:
schedule:
# Everyday at 4:00 AM
Expand Down Expand Up @@ -289,6 +290,12 @@ jobs:
cache: 'yarn'
cache-dependency-path: docs/yarn.lock

- name: ❓ Test api reference
working-directory: docs
run: |
yarn
yarn validate
- name: 📥 Download generated documentation
uses: actions/download-artifact@v3
with:
Expand All @@ -301,21 +308,31 @@ jobs:
name: test-results
path: docs/benchmarks/tests

- name: 📚 Documentation (Docusaurus)
- name: 📚 Documentation (unstable)
working-directory: docs
run: |
sed -i 's|head-protocol|head-protocol/unstable|' docusaurus.config.js
yarn && yarn build
yarn validate
mkdir -p public/head-protocol
mv build/* public/head-protocol
echo "hydra.family" > public/CNAME
echo '<!DOCTYPE html><html><head><meta http-equiv="Refresh" content="0; URL=https://hydra.family/head-protocol"></head></html>' > public/index.html
- name: 🚢 Publish Documentation
if: github.event_name == 'push'
uses: peaceiris/actions-gh-pages@v3
mkdir -p public/unstable
mv build/* public/unstable
- name: 💾 Upload docs artifact (unstable)
uses: actions/upload-artifact@v3
with:
name: unstable
path: docs/public/unstable

- name: 📚 Documentation (stable) - only release branch
if: github.ref_name == 'release'
working-directory: docs
run: |
yarn && yarn build
mkdir -p public/
mv build/* public/
- name: 💾 Upload docs artifact (stable) - only release branch
if: github.ref_name == 'release'
uses: actions/upload-artifact@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN || github.token }}
publish_dir: docs/public
enable_jekyll: true
force_orphan: true
name: stable
path: docs/public
54 changes: 54 additions & 0 deletions .github/workflows/publish-docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: "Publish Docs"

on:
workflow_run:
workflows: ["CI"]
branches: [master, release]
types:
- completed

jobs:
publishing:
name: Publish Documentation
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: 📥 Download stable (last released) docs
uses: dawidd6/action-download-artifact@v2
with:
workflow: ci.yaml
workflow_conclusion: success
branch: release
name: stable
path: docs/public/

- name: 📥 Download & merge unstable docs with released
uses: dawidd6/action-download-artifact@v2
with:
workflow: ci.yaml
workflow_conclusion: success
branch: master
name: unstable
path: docs/public/unstable

# TODO: remove debugging steps

- name: DEBUG contents
run: |
find docs/
- name: DEBUG contents
uses: actions/upload-artifact@v3
with:
name: head-protocol
path: docs/public

- name: 🚢 Publish Documentation
if: github.event_name == 'push'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN || github.token }}
publish_dir: docs/public
enable_jekyll: true
force_orphan: true

0 comments on commit d050f28

Please sign in to comment.