-
Notifications
You must be signed in to change notification settings - Fork 19
137 lines (119 loc) · 4.62 KB
/
make-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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
name: Make-docs-to-webpage
# Trigger whenever changes are made to the main branch
on:
push:
branches:
- main
jobs:
make_docs:
name: Update DB schema files in webpage
runs-on: ubuntu-latest
services:
postgres:
image: postgres:14.8
env:
POSTGRES_DB: caseflow_certification_test
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
ports: ["5432:5432"]
redis:
image: redis:2.8.23
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports: ["6379:6379"]
steps:
- name: Debugging info
# https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#pull_request
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: |
# prints GITHUB_CONTEXT env variable
env
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Ruby and install gems
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Setup test database
env:
RAILS_ENV: make_docs
POSTGRES_HOST: localhost
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
run: |
echo "::group::Set up Caseflow DB"
bin/rails db:create:primary && bin/rails db:schema:load:primary
echo "::endgroup::"
echo "::group::Set up Caseflow ETL DB"
bundle exec rake db:create:etl db:schema:load:etl
echo "::endgroup::"
# Skipping VACOLS since Oracle DB is not set up
# bundle exec rake spec:setup_vacols
# Need graphviz to create ERDs
- name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@v1
- name: Create DB schema documentation
env:
RAILS_ENV: make_docs
POSTGRES_HOST: localhost
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
UPDATE_SCHEMA_ERD_IMAGES: true
run: |
ln -s Makefile.example Makefile
echo "::group::Caseflow schema"
make erd-caseflow doc-schema-caseflow
echo "::endgroup::"
echo "::group::Caseflow ETL schema"
make erd-etl doc-schema-etl
echo "::endgroup::"
# Skipping VACOLS since Oracle DB is not set up
# make erd-vacols
# The following is adapted from: https://github.com/SwiftDocOrg/github-wiki-publish-action/blob/v1/entrypoint.sh
# and https://github.com/Andrew-Chen-Wang/github-wiki-action/blob/master/entrypoint.sh
# and https://github.community/t/how-to-updade-repo-wiki-from-github-actions/121151/7
- name: Checkout branch main-gh-pages
uses: actions/checkout@v4
with:
ref: main-gh-pages
path: main-gh-pages_checkout
- name: Copy results of `make docs` to checkout of main-gh-pages
run: |
rsync -av --exclude .git --exclude .keep "docs/schema/" "main-gh-pages_checkout/schema/make_docs/"
- name: Update Jailer-generated DB schema docs for Caseflow using results of `make docs`
env:
POSTGRES_DB: caseflow_certification_test
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
run: |
CASEFLOW_HOME=`pwd`
cd main-gh-pages_checkout/schema/bin
sh ./gen_jailer_schema_docs.sh "$CASEFLOW_HOME" ../make_docs/caseflow-jailer_polymorphic_associations.csv
- name: Compare (and locally commit) generated docs against main-gh-pages branch
id: compare_docs
env:
WIKI_COMMIT_MESSAGE: '`make docs` GH Action: automatically update DB schema documentation files'
WIKI_COMMIT_USER_EMAIL: '[email protected]'
WIKI_COMMIT_USER_NAME: 'samantha-quillman'
run: |
cd main-gh-pages_checkout
make github_action_pre_commit_hook
git add .
if git diff-index --quiet HEAD; then
echo "name=changes_docs::false" >> $GITHUB_OUTPUT
echo "::group::No changes to make_docs"
ls -alR schema/make_docs
echo "::endgroup::"
else
echo "name=changes_docs::true" >> $GITHUB_OUTPUT
echo "::group::Committing changes locally"
git config --local user.email "$WIKI_COMMIT_USER_EMAIL"
git config --local user.name "$WIKI_COMMIT_USER_NAME"
git commit -m "$WIKI_COMMIT_MESSAGE" && git push
echo "::endgroup::"
fi