Skip to content

Commit 3424d4f

Browse files
committed
feat: update workflows to support docs versioning
1 parent d369f5e commit 3424d4f

File tree

3 files changed

+42
-49
lines changed

3 files changed

+42
-49
lines changed

.github/workflows/publish.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ jobs:
3131
runs-on: ubuntu-latest
3232
steps:
3333
- uses: actions/checkout@v2
34+
with:
35+
fetch-depth: 0
3436
- name: Set up Python
3537
uses: actions/setup-python@v1
3638
with:
@@ -68,7 +70,21 @@ jobs:
6870
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
6971
AWS_DEFAULT_REGION: eu-west-1
7072
AWS_DEFAULT_OUTPUT: json
71-
73+
- name: Setup doc deploy
74+
run: |
75+
git config --global user.name Docs deploy
76+
git config --global user.email docs@dummy.bot.com
77+
- name: Build docs website and API reference
78+
run: make release-docs VERSION=${RELEASE_TAG_VERSION} ALIAS="latest"
79+
- name: Update docs redirects
80+
run: poetry run mike set-default --push latest
81+
- name: Deploy all docs
82+
uses: peaceiris/actions-gh-pages@v3
83+
with:
84+
github_token: ${{ secrets.GITHUB_TOKEN }}
85+
publish_dir: ./api
86+
keep_files: true
87+
destination_dir: develop/api
7288

7389

7490
sync_master:

.github/workflows/python_docs.yml

Lines changed: 15 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,38 @@
11
name: Docs
22

33
on:
4-
pull_request:
5-
branches:
6-
- master
74
push:
85
branches:
9-
- master
10-
- docs/mkdocs
11-
# Disabled until docs support versioning per branch/release
12-
# - develop
13-
release:
14-
types: [published] # update Docs upon new release
6+
- develop
157

168
jobs:
179
api-docs:
1810
runs-on: ubuntu-latest
1911
steps:
20-
- uses: actions/checkout@v1
12+
- uses: actions/checkout@v2
13+
with:
14+
fetch-depth: 0
2115
- name: Set up Python
2216
uses: actions/setup-python@v1
2317
with:
2418
python-version: "3.8"
25-
- uses: actions/setup-node@v1
26-
with:
27-
node-version: '12'
2819
- name: Capture branch and tag
2920
id: branch_name
3021
run: |
3122
echo "SOURCE_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
3223
echo "SOURCE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
33-
- name: Build docs website
34-
run: make build-docs-website
35-
- name: Build docs API reference
36-
# if: env.SOURCE_BRANCH == 'master' # Disabled until docs support versioning per branch/release
37-
run: make build-docs-api
24+
- name: Install dependencies
25+
run: make dev
26+
- name: Setup doc deploy
27+
run: |
28+
git config --global user.name Docs deploy
29+
git config --global user.email docs@dummy.bot.com
30+
- name: Build docs website and API reference
31+
run: make release-docs VERSION="develop" ALIAS="stage"
3832
- name: Deploy all docs
3933
uses: peaceiris/actions-gh-pages@v3
4034
with:
4135
github_token: ${{ secrets.GITHUB_TOKEN }}
42-
publish_dir: ./dist
43-
44-
# Disabled until docs support versioning per branch/release
45-
# - name: Deploy docs website
46-
# uses: peaceiris/actions-gh-pages@v3
47-
# with:
48-
# github_token: ${{ secrets.GITHUB_TOKEN }}
49-
# publish_dir: ./dist
50-
# # when deploying docs website only
51-
# # we need to keep existing API docs checked in
52-
# # but only for dev branch
53-
# keep_files: true
54-
# - name: Deploy all docs
55-
# uses: peaceiris/actions-gh-pages@v3
56-
# if: env.SOURCE_BRANCH == 'master'
57-
# with:
58-
# github_token: ${{ secrets.GITHUB_TOKEN }}
59-
# publish_dir: ./dist
36+
publish_dir: ./api
37+
keep_files: true
38+
destination_dir: develop/api

Makefile

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,18 @@ pr: lint test security-baseline complexity-baseline
2828
build: pr
2929
poetry build
3030

31-
build-docs:
32-
@$(MAKE) build-docs-website
31+
release-docs:
32+
@echo "Rebuilding docs"
33+
rm -rf site api
34+
@echo "Updating website docs"
35+
poetry run mike deploy --push --update-aliases ${VERSION} ${ALIAS}
36+
@echo "Building API docs"
3337
@$(MAKE) build-docs-api
3438

35-
build-docs-api: dev
36-
mkdir -p dist/api
37-
poetry run pdoc --html --output-dir dist/api/ ./aws_lambda_powertools --force
38-
mv -f dist/api/aws_lambda_powertools/* dist/api/
39-
rm -rf dist/api/aws_lambda_powertools
40-
41-
build-docs-website: dev
42-
mkdir -p dist
43-
poetry run mkdocs build
44-
cp -R site/* dist/
39+
build-docs-api:
40+
poetry run pdoc --html --output-dir ./api/ ./aws_lambda_powertools --force
41+
mv -f ./api/aws_lambda_powertools/* ./api/
42+
rm -rf ./api/aws_lambda_powertools
4543

4644
docs-local:
4745
poetry run mkdocs serve

0 commit comments

Comments
 (0)