Merge pull request #455 from jistr/b/docs-broken-link #925
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Docs | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
paths: | |
- .github/workflows/docs* | |
- docs_dev/** | |
- docs_user/** | |
- Gemfile | |
- Makefile | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
# this fetches all branches. Needed because we need gh-pages branch for deploy to work | |
fetch-depth: 0 | |
- uses: actions/setup-python@v2 | |
with: | |
python-version: '3.9' | |
- uses: ruby/[email protected] | |
with: | |
ruby-version: '3.2' | |
- name: Install Asciidoc | |
run: make docs-dependencies | |
- name: Build upstream user docs | |
run: make docs-user | |
- name: Build downstream preview of user docs | |
run: BUILD=downstream make docs-user | |
- name: Build dev docs | |
run: make docs-dev | |
- name: Test user docs | |
run: | | |
INSTALL_YAMLS_REF=$(grep -o install_yamls docs_build/adoption-user/index-downstream.html | wc -l) | |
if [[ $INSTALL_YAMLS_REF -gt 0 ]]; then | |
echo user facing docs should NOT mention install_yamls | |
grep install_yamls docs_build/adoption-user/index-downstream.html | |
exit 1 | |
fi | |
- name: Prepare gh-pages branch | |
run: | | |
git config user.name github-actions | |
git config user.email [email protected] | |
git branch -D gh-pages &>/dev/null || true | |
git checkout -b gh-pages aabb4803f89a3b006094d8ae7a933650f644d036 | |
- name: Create index.html | |
run: | | |
cat > index.html <<EOF | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<style> | |
body { | |
margin: 0; | |
font-family: Arial, Helvetica, sans-serif; | |
} | |
.asciidoc { | |
height:90vh; | |
background:#fff; | |
color:#fff; | |
} | |
.topnav { | |
overflow: hidden; | |
background-color: #333; | |
} | |
.topnav a { | |
float: left; | |
color: #f2f2f2; | |
text-align: center; | |
padding: 2vh 2vh; | |
text-decoration: none; | |
font-size: 2vh; | |
} | |
.topnav a:hover { | |
background-color: #ddd; | |
color: black; | |
} | |
.topnav a.active { | |
background-color: #7a2518; | |
color: white; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="topnav"> | |
<a class="active" href="user/" target="content">User</a> | |
<a href="dev/" target="content">Contributor</a> | |
</div> | |
<div class="asciidoc"> | |
<iframe name="content" width="100%" height="100%" src="user/index.html"></iframe> | |
</div> | |
</body> | |
</html> | |
EOF | |
- name: Commit asciidoc docs | |
run: | | |
mv -T docs_build/adoption-user user | |
mv -T docs_build/adoption-dev dev | |
mv user/index-upstream.html user/index.html | |
mv user/index-downstream.html user/downstream.html | |
mv dev/index-upstream.html dev/index.html | |
git add user | |
git add dev | |
git add index.html | |
git commit -m "Rendered docs" | |
- name: Push rendered docs to gh-pages | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
run: | | |
git push --force origin gh-pages |