forked from aws-powertools/powertools-lambda-python
-
Notifications
You must be signed in to change notification settings - Fork 1
83 lines (79 loc) · 2.69 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
name: Reusable publish documentation
env:
BRANCH: develop
ORIGIN: awslabs/aws-lambda-powertools-python
on:
workflow_call:
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
pages: write
jobs:
publish_docs:
# Force Github action to run only a single job at a time (based on the group name)
# This is to prevent "race-condition" in publishing a new version of doc to `gh-pages`
concurrency:
group: on-docs-rebuild
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install poetry
run: pipx install poetry
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.8"
cache: "poetry"
- name: Install dependencies
run: make dev
- name: Git client setup
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: Build docs website and API reference
env:
VERSION: ${{ inputs.version }}
ALIAS: ${{ inputs.alias }}
run: |
make release-docs VERSION="$VERSION" ALIAS="$ALIAS"
poetry run mike set-default --push latest
# Maintenance: Migrate to new gh-pages action
- name: Release API docs
uses: peaceiris/actions-gh-pages@64b46b4226a4a12da2239ba3ea5aa73e3163c75b # v3.9.1
env:
VERSION: ${{ inputs.version }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./api
keep_files: true
destination_dir: ${{ env.VERSION }}/api
- name: Release API docs to latest
if: ${{ inputs.alias == 'latest' }}
uses: peaceiris/actions-gh-pages@64b46b4226a4a12da2239ba3ea5aa73e3163c75b # v3.9.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./api
keep_files: true
destination_dir: latest/api