-
Notifications
You must be signed in to change notification settings - Fork 153
128 lines (124 loc) · 4.31 KB
/
reusable-publish-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
name: Reusable Publish docs
env:
BRANCH: main
ORIGIN: aws-powertools/powertools-lambda-typescript
VERSION: ""
on:
workflow_call:
secrets:
AWS_DOCS_ROLE_ARN:
description: zomg
required: false
AWS_DOCS_BUCKET:
description: zomg
required: false
inputs:
version:
description: "Version to build and publish docs (1.28.0, develop)"
required: true
type: string
alias:
description: "Alias to associate version (latest, stage)"
required: true
type: string
detached_mode:
description: "Whether it's running in git detached mode to ensure git is sync'd"
required: false
default: false
type: boolean
permissions:
contents: write
id-token: write
pages: write
jobs:
publish-docs:
runs-on: ubuntu-latest
environment: Docs
steps:
- name: Checkout code
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
with:
# While `fetch-depth` is used to allow the workflow to later commit & push the changes.
fetch-depth: 0
- name: Setup NodeJS
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version: "18"
cache: "npm"
- name: Setup dependencies
uses: ./.github/actions/cached-node-modules
- name: Set up Python
uses: actions/setup-python@57ded4d7d5e986d7296eab16560982c6dd7c923b # v4.6.0
with:
python-version: "3.8"
- name: Install doc generation dependencies
run: |
pip install --upgrade pip
pip install -r docs/requirements.txt
- name: Setup doc deploy
run: |
git config --global user.name Docs deploy
git config --global user.email [email protected]
- name: Git refresh tip (detached mode)
# Git Detached mode (release notes) doesn't have origin
if: ${{ inputs.detached_mode }}
run: |
git config pull.rebase true
git config remote.origin.url >&- || git remote add origin https://github.com/"$ORIGIN"
git pull origin "$BRANCH"
- name: Normalize Version Number
run: echo "VERSION=$(echo ${{ inputs.version }} | sed 's/v//')" >> $GITHUB_ENV
- name: Build docs website and API reference
env:
ALIAS: ${{ inputs.alias }}
run: |
rm -rf site
mkdocs build
mike deploy --push --update-aliases --no-redirect ${{ env.VERSION }} ${{ env.ALIAS }} --branch backup-gh-pages
# Set latest version as a default
mike set-default --push latest --branch backup-gh-pages
- name: Build API docs
run: |
rm -rf api
npm run docs-generateApiDoc
- name: Release API docs
uses: peaceiris/actions-gh-pages@bd8c6b06eba6b3d25d72b7a1767993c0aeee42e7 # v3.9.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./api
keep_files: true
destination_dir: ${{ env.VERSION }}/api
publish_branch: 'backup-gh-pages'
- name: Release API docs to latest
if: ${{ inputs.alias == 'latest' }}
uses: peaceiris/actions-gh-pages@bd8c6b06eba6b3d25d72b7a1767993c0aeee42e7 # v3.9.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./api
keep_files: true
destination_dir: latest/api
publish_branch: 'backup-gh-pages'
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@e1e17a757e536f70e52b5a12b2e8d1d1c60e04ef # v2.0.0
with:
aws-region: us-east-1
role-to-assume: ${{ secrets.AWS_DOCS_ROLE_ARN }}
- name: Copy API Docs
run: |
cp -r api site/
- name: Deploy Docs (Version)
env:
VERSION: ${{ inputs.version }}
ALIAS: ${{ inputs.alias }}
run: |
aws s3 sync \
site/ \
s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-typescript/${{ env.VERSION }}/
- name: Deploy Docs (Alias)
env:
VERSION: ${{ inputs.version }}
ALIAS: ${{ inputs.alias }}
run: |
aws s3 sync \
site/ \
s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-typescript/${{ env.ALIAS }}/