-
Notifications
You must be signed in to change notification settings - Fork 39
92 lines (87 loc) · 3.1 KB
/
doc.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
name: Docs Deployment
on:
push:
branches:
- v*
- main
workflow_dispatch: {}
env:
AWS_REGION: "us-east-2"
S3_BUCKET_NAME: paraspace-core-docs
CLOUDFLARE_PURGE_URLS: '["https://api-docs.para.space/"]'
AWS_CLOUDFRONT_DISTRIBUTION_ID: "E29T1DS5QA33RG"
jobs:
deploy-output-to-s3:
name: Deploy output files to S3
runs-on: ubuntu-latest
strategy:
matrix:
node: [18]
steps:
- name: Checkout Repository
uses: actions/checkout@v3
with:
token: ${{ secrets.PAT }}
submodules: true
- name: Setup nodejs
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
registry-url: https://registry.npmjs.org
- name: Generate Documentation
run: |
yarn
yarn build
yarn doc
mkdir bin
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.21/mdbook-v0.4.21-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin
bin/mdbook init paraspace-core-docs --title "paraspace core" --ignore none
rm -rf paraspace-core-docs/src/* && mv docs/* paraspace-core-docs/src/
rm paraspace-core-docs/src/DEVELOPER-GUIDE.md
- name: Generate Summary
uses: actions-rs/toolchain@v1
with:
toolchain: stable
- uses: actions-rs/cargo@v1
with:
command: install
args: mdbook-auto-gen-summary
- name: Build Documentation
run: |
mdbook-auto-gen-summary gen paraspace-core-docs/src
bin/mdbook build paraspace-core-docs
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.DEPLOYMENT_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DEPLOYMENT_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Upload to S3
run: |
aws s3 sync ./paraspace-core-docs/book s3://${{ env.S3_BUCKET_NAME }}/ --acl public-read --delete
- name: slack
uses: 8398a7/action-slack@v3
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
with:
status: ${{ job.status }}
fields: repo,message,commit,author,eventName,ref,workflow
if: always()
clear-cache:
name: Clear-cache
needs: [deploy-output-to-s3]
runs-on: ubuntu-latest
steps:
- name: Purge cloudflare cache
uses: jakejarvis/cloudflare-purge-action@master
env:
CLOUDFLARE_ZONE: ${{ secrets.CLOUDFLARE_ZONE }}
CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }}
PURGE_URLS: ${{ env.CLOUDFLARE_PURGE_URLS }}
- name: Purge cloudfront cache
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.DEPLOYMENT_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DEPLOYMENT_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- run: aws cloudfront create-invalidation --distribution-id "${{ env.AWS_CLOUDFRONT_DISTRIBUTION_ID }}" --paths '/*'