This repository has been archived by the owner on Feb 1, 2024. It is now read-only.
Update README.md #166
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
# Generate documentation and associated files | |
# If file gets unweildy with just one job, could refactor to use outputs: | |
# https://docs.github.com/en/actions/using-jobs/defining-outputs-for-jobs | |
# This name is referenced by gh-pages.yml workflow. Update there if this changes. | |
name: Docs | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- '**' | |
workflow_dispatch: | |
inputs: | |
deploy_docs: | |
type: boolean | |
description: 'Run the deploy-to-gh-pages step' | |
required: false | |
default: false | |
debug_enabled: | |
type: boolean | |
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)' | |
required: false | |
default: false | |
jobs: | |
build-erd: | |
runs-on: ubuntu-latest | |
env: | |
POSTGRES_PASSWORD: "galv" | |
DJANGO_SECRET_KEY: "long-and-insecure-key-12345" | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install additional requirements | |
run: | | |
sudo apt-get install -y graphviz | |
sudo pip install sphinx | |
mkdir docs/source/resources | |
echo "POSTGRES_PASSWORD=$POSTGRES_PASSWORD" > .env.secret | |
echo "DJANGO_SECRET_KEY=$DJANGO_SECRET_KEY" >> .env.secret | |
echo "django-extensions==3.2.1" >> backend/requirements.txt | |
sed -i "s+'rest_framework',+'rest_framework', 'django_extensions',+g" backend/backend_django/config/settings_prod.py | |
- name: Create Entity Relationship Diagram | |
run: | | |
docker-compose -f docker-compose.docs.yml run app python manage.py graph_models --dot --output output.dot galv | |
dot -Tpng backend/backend_django/output.dot -o docs/source/resources/ERD.png | |
- name: Create API spec | |
run: | | |
docker-compose -f docker-compose.docs.yml run app python manage.py spectacular --file schema.yml | |
docker-compose -f docker-compose.docs.yml run app python manage.py spectacular --format openapi-json --file schema.json | |
mv backend/backend_django/schema.* docs/source/resources/ | |
# - name: Create API client | |
# run: | | |
# echo "{\"lang\": \"python\", \"type\": \"CLIENT\", \"codegenVersion\": \"V3\", \"spec\": $(cat docs/schema.json)}" > payload.json | |
# curl -d @payload.json --output docs/source/resources/galv-client-python.zip -H "Content-Type: application/json" https://generator3.swagger.io/api/generate | |
# # Check size | |
# if [ ! -s docs/source/resources/galv-client-python.zip ]; then | |
# echo "Downloaded python client zip file is zero bytes" | |
# exit 1 | |
# fi | |
# # Check we can unzip | |
# unzip -t docs/source/resources/galv-client-python.zip | |
# Enable tmate debugging of manually-triggered workflows if the input option was provided | |
- name: Setup tmate session | |
uses: mxschmitt/action-tmate@v3 | |
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }} | |
- name: Sphinx build | |
run: | | |
cd docs | |
make html | |
- name: Push to gh-pages branch | |
if: (github.ref_name == 'main' && github.event_name == 'push') || inputs.deploy_docs | |
run: | | |
git worktree add gh-pages | |
git config user.name "Deploy from CI" | |
git config user.email "" | |
cd gh-pages | |
# Delete the ref to avoid keeping history. | |
git update-ref -d refs/heads/gh-pages | |
rm -rf * | |
mv ../docs/build/html/* . | |
git add . | |
git commit -m "Deploy $GITHUB_SHA to gh-pages" | |
git push --set-upstream origin gh-pages --force |