-
Notifications
You must be signed in to change notification settings - Fork 15
99 lines (78 loc) · 2.9 KB
/
preview_pr.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
name: Preview Docs
on:
pull_request:
branches:
- master
jobs:
build:
env:
# Set up docs preview only for PRs from the upstream repository, not from forks.
DOCS_PR_PREVIEW: ${{ github.event_name == 'pull_request' && !github.event.pull_request.head.repo.fork }}
runs-on: ubuntu-20.04
steps:
- name: Checkout DHIS2 Docs Builder Repository
uses: actions/checkout@v4
with:
repository: dhis2/dhis2-docs-builder
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Install custom pre-processor
run: |
cd tools/python/markdown-pp-master
python3 setup.py develop
pip install MarkdownPP
- name: Install markdown extensions
run: |
cd tools/python/markdown-extensions/d_card
python3 setup.py develop
pip install d_card
- name: Install dhis2_plugins for mkdocs
run: |
cd tools/python/dhis2_plugins
python3 setup.py develop
pip install dhis2_plugins
- name: Install markdown hacks
run: |
# temporary hacks
python3 -m site
cp tools/python/blockprocessors.py ${pythonLocation}/lib/python3.9/site-packages/markdown/
cp tools/python/attr_list.py ${pythonLocation}/lib/python3.9/site-packages/markdown/extensions/
cp tools/python/tables.py ${pythonLocation}/lib/python3.9/site-packages/markdown/extensions/
- name: Install node
uses: actions/setup-node@v3
with:
node-version: '16'
- name: install prettier
run: npm install -g prettier
- name: Run sed Command
run: |
sed -i "s;\(github(dhis2/dhis2-docs-implementation,.*, \)master);\1${GITHUB_HEAD_REF});" mkdocs.yml
cat mkdocs.yml
- name: Build the docs
run: |
mkdocs build
- name: Sync docs to S3 for PR preview
if: ${{ env.DOCS_PR_PREVIEW == 'true' }}
uses: dhis2/s3-sync-action@master
# with:
# args: --delete --exclude 'full*'
env:
AWS_S3_BUCKET: ${{ secrets.DHIS2_S3_DOCS_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.DHIS2_S3_DOCS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DHIS2_S3_DOCS_ACCESS_KEY }}
AWS_REGION: 'eu-west-1'
SOURCE_DIR: 'target/en/.'
DEST_DIR: "temp/PR/implementer-${GITHUB_HEAD_REF}/en/"
- name: Add comment with preview link
if: ${{ env.DOCS_PR_PREVIEW == 'true' }}
uses: peter-evans/create-or-update-comment@a35cf36e5301d70b76f316e867e7788a55a31dae
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
CI Preview: https://docs.dhis2.org/temp/PR/implementer-${{ github.event.pull_request.head.ref }}/en/home.html