-
Notifications
You must be signed in to change notification settings - Fork 3
90 lines (76 loc) · 3.13 KB
/
generate-db-docs.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
name: Generate db docs
on:
push:
branches:
- master
jobs:
generate-db-docs:
runs-on: ubuntu-latest
container: eu.gcr.io/moocfi-public/db-docs
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Set up deploy key
run: |
mkdir -p ~/.ssh
echo "$DB_DOCS_DEPLOY_KEY" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
md5sum ~/.ssh/id_ed25519
ls -la ~/.ssh
env:
DB_DOCS_DEPLOY_KEY: ${{ secrets.DB_DOCS_DEPLOY_KEY }}
- name: Check out docs repo
run: git clone git@github.com:rage/secret-project-331-db-docs.git db-docs
env:
GIT_SSH_COMMAND: "ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_ed25519 -o IdentitiesOnly=yes"
- name: Setup database
run: sqlx database setup
working-directory: ./services/headless-lms
env:
DATABASE_URL: postgres://postgres:postgres@postgres/headless_lms_dev
- name: Generate tbls docs
run: tbls doc 'postgres://postgres:postgres@postgres/headless_lms_dev?sslmode=disable' db-docs --force --sort
# Column comments can be quite long and they are a bit too much text for the whole
# entity relationship diagram so we'll remove them from the diagram.
# Note that the column comments are still visible from the markdown documentation.
- name: Remove all column comments
run: psql 'postgres://postgres:postgres@postgres/headless_lms_dev?sslmode=disable' -c 'DELETE FROM pg_description WHERE objsubid > 0;'
- name: Generate uml with planter
run: planter 'postgres://postgres:postgres@postgres/headless_lms_dev?sslmode=disable' -o db-docs/schema.uml
- name: Patch uml to work with wide comments
run: sed -i 's/skinparam linetype ortho/skinparam linetype ortho\nskinparam wrapWidth 300/' db-docs/schema.uml
- name: Generate plantuml svg
run: plantuml -tsvg schema.uml
working-directory: ./db-docs
- name: Generate html with Pandoc
run: |
for f in *.md; do
# remove .md extension
f2=${f%.md}
# convert to html
pandoc -f markdown -t html5 "$f" -o "$f2.html" --lua-filter=../misc/db-docs/pandoc-links-md-extension-to-html-extension.lua --template ../misc/db-docs/template.html
cp README.html index.html
done
working-directory: ./db-docs
- name: Commit files
run: |
git config --local user.email "bot@example.com"
git config --local user.name "github-actions[bot]"
git add .
git commit -m "Update: $GITHUB_SHA" --allow-empty
working-directory: ./db-docs
- name: Push changes
run: git push
env:
GIT_SSH_COMMAND: "ssh -o StrictHostKeyChecking=no -i ~/.ssh/id_ed25519 -o IdentitiesOnly=yes"
working-directory: ./db-docs