File tree Expand file tree Collapse file tree 7 files changed +103
-1
lines changed Expand file tree Collapse file tree 7 files changed +103
-1
lines changed Original file line number Diff line number Diff line change 1
- name : Build and Deploy to Netlify
1
+ name : Build Docs
2
2
on :
3
3
push :
4
4
pull_request :
18
18
run : python3.7 -m flit install --extras doc
19
19
- name : Build Docs
20
20
run : python3.7 ./scripts/docs.py build-all
21
+ - name : Zip docs
22
+ run : bash ./scripts/zip-docs.sh
23
+ - uses : actions/upload-artifact@v2
24
+ with :
25
+ name : docs-zip-${{ github.sha }}
26
+ path : ./docs.zip
27
+ - name : Trigger Docs Preview
28
+ env :
29
+ PR : " ${{ github.event.number }}"
30
+ NAME : " docs-zip-${{ github.sha }}"
31
+ GITHUB_TOKEN : " ${{ secrets.GITHUB_TOKEN }}"
32
+ run : bash ./scripts/trigger-docs-preview.sh
21
33
- name : Deploy to Netlify
22
34
uses : nwtgck/actions-netlify@v1.0.3
23
35
with :
Original file line number Diff line number Diff line change
1
+ name : Deploy Docs
2
+ on :
3
+ workflow_dispatch :
4
+ inputs :
5
+ pr :
6
+ description : Pull Request number
7
+ required : true
8
+ name :
9
+ description : Artifact name for zip file with docs
10
+ required : true
11
+
12
+ jobs :
13
+ deploy :
14
+ runs-on : ubuntu-18.04
15
+ steps :
16
+ - uses : actions/download-artifact@v2
17
+ with :
18
+ name : ${{ github.event.inputs.name }}
19
+ path : ./docs.zip
20
+ - name : Unzip docs
21
+ run : bash ./scripts/unzip-docs.sh
22
+ - name : Deploy to Netlify
23
+ id : netlify
24
+ uses : nwtgck/actions-netlify@v1.0.3
25
+ with :
26
+ publish-dir : ' ./site'
27
+ production-deploy : false
28
+ github-token : ${{ secrets.GITHUB_TOKEN }}
29
+ env :
30
+ NETLIFY_AUTH_TOKEN : ${{ secrets.NETLIFY_AUTH_TOKEN }}
31
+ NETLIFY_SITE_ID : ${{ secrets.NETLIFY_SITE_ID }}
32
+ - name : Comment Deploy
33
+ run : bash ./scripts/docs-comment-deploy.sh
34
+ env :
35
+ PR : " ${{ github.event.inputs.pr }}"
36
+ DEPLOY_URL : " ${{ steps.netlify.outputs.deploy-url }}"
37
+ GITHUB_TOKEN : " ${{ secrets.GITHUB_TOKEN }}"
Original file line number Diff line number Diff line change 17
17
env
18
18
docs_build
19
19
venv
20
+ docs.zip
20
21
21
22
# vim temporary files
22
23
* ~
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ set -x
4
+ set -e
5
+
6
+ PR=${PR:? Variable not set}
7
+ DEPLOY_URL=${DEPLOY_URL:? Variable not set}
8
+ GITHUB_TOKEN=${GITHUB_TOKEN:? Variable not set}
9
+
10
+ curl \
11
+ -H " Authorization: token ${GITHUB_TOKEN} " \
12
+ https://api.github.com/repos/tiangolo/fastapi/issues/${PR} /comments \
13
+ -d ' {"body": "📝 Docs preview: ' " ${DEPLOY_URL} " ' "}'
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ set -x
4
+ set -e
5
+
6
+ PR=${PR}
7
+
8
+ if [ -z " $PR " ]; then
9
+ echo " Not a PR build, skip trigger docs preview"
10
+ exit 0
11
+ fi
12
+
13
+ NAME=${NAME:? Variable not set}
14
+ GITHUB_TOKEN=${GITHUB_TOKEN:? Variable not set}
15
+
16
+ curl \
17
+ -X POST \
18
+ -H " Authorization: token ${GITHUB_TOKEN} " \
19
+ -H " Accept: application/vnd.github.v3+json" \
20
+ https://api.github.com/repos/tiangolo/fastapi/actions/workflows/preview-docs.yml/dispatches \
21
+ -d ' {"ref":"master", "inputs": {"pr": "' " ${PR} " ' ", "name": "' " ${NAME} " ' "}}'
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ set -x
4
+ set -e
5
+
6
+ if [ -d ./site/ ]; then
7
+ rm -rf ./site/
8
+ fi
9
+ unzip docs.zip
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ set -x
4
+ set -e
5
+
6
+ if [ -f docs.zip ]; then
7
+ rm -rf docs.zip
8
+ fi
9
+ zip -r docs.zip ./site
You can’t perform that action at this time.
0 commit comments