|
1 | 1 | name: Reusable Publish docs
|
2 | 2 |
|
| 3 | +env: |
| 4 | + BRANCH: main |
| 5 | + ORIGIN: awslabs/aws-lambda-powertools-typescript |
| 6 | + |
| 7 | + |
3 | 8 | on:
|
4 | 9 | workflow_call:
|
5 | 10 | inputs:
|
6 |
| - workflow_origin: # see https://github.com/awslabs/aws-lambda-powertools-python/issues/1349 |
| 11 | + version: |
| 12 | + description: "Version to build and publish docs (1.28.0, develop)" |
7 | 13 | required: true
|
8 | 14 | type: string
|
9 |
| - prIsMerged: |
10 |
| - required: false |
11 |
| - default: "false" |
12 |
| - type: string |
13 |
| - isRelease: |
14 |
| - required: false |
15 |
| - default: "false" |
| 15 | + alias: |
| 16 | + description: "Alias to associate version (latest, stage)" |
| 17 | + required: true |
16 | 18 | type: string
|
17 |
| - versionNumber: |
| 19 | + detached_mode: |
| 20 | + description: "Whether it's running in git detached mode to ensure git is sync'd" |
18 | 21 | required: false
|
19 |
| - default: "" |
| 22 | + default: false |
| 23 | + type: boolean |
| 24 | + workflow_origin: # see https://github.com/awslabs/aws-lambda-powertools-python/issues/1349 |
| 25 | + required: true |
20 | 26 | type: string
|
21 | 27 | secrets:
|
22 | 28 | token:
|
@@ -65,68 +71,48 @@ jobs:
|
65 | 71 | uses: actions/setup-python@v4
|
66 | 72 | with:
|
67 | 73 | python-version: "3.8"
|
68 |
| - # We run this step only when the workflow has been triggered by a release |
69 |
| - # in this case we publish the docs to `/latest` |
70 |
| - - name: (Conditional) Set RELEASE_VERSION env var to `latest` |
71 |
| - if: ${{ inputs.isRelease == 'true' }} |
72 |
| - run: | |
73 |
| - RELEASE_VERSION=$(echo ${{ github.ref_name }} | sed 's/v//') |
74 |
| - EXPLICIT_RELEASE_VERSION=$(echo ${{ inputs.versionNumber }} | sed 's/v//') |
75 |
| - if [ $EXPLICIT_RELEASE_VERSION != "" ]; then |
76 |
| - echo "RELEASE_VERSION=${EXPLICIT_RELEASE_VERSION}" |
77 |
| - echo "RELEASE_VERSION=${EXPLICIT_RELEASE_VERSION}" >> $GITHUB_ENV |
78 |
| - else |
79 |
| - echo "RELEASE_VERSION=${RELEASE_VERSION}" |
80 |
| - echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV |
81 |
| - fi |
82 |
| - # We run this step only when the workflow has been triggered by a PR merge |
83 |
| - # in this case we publish the docs to `/dev` |
84 |
| - - name: (Conditional) Set RELEASE_VERSION env var to `dev` |
85 |
| - if: ${{ inputs.prIsMerged == 'true' }} |
86 |
| - run: | |
87 |
| - echo "RELEASE_VERSION=dev" >> $GITHUB_ENV |
88 |
| - - name: Check RELEASE_VERSION env var |
89 |
| - if: ${{ env.RELEASE_VERSION == '' }} |
90 |
| - uses: actions/github-script@v3 |
91 |
| - with: |
92 |
| - script: | |
93 |
| - core.setFailed('RELEASE_VERSION env var is empty.') |
94 | 74 | - name: Install doc generation dependencies
|
95 | 75 | run: |
|
96 | 76 | pip install --upgrade pip
|
97 | 77 | pip install -r docs/requirements.txt
|
98 | 78 | - name: Setup doc deploy
|
99 | 79 | run: |
|
100 | 80 | git config --global user.name Docs deploy
|
101 |
| - git config --global user.email [email protected] |
102 |
| - - name: Publish docs to latest if isRelease |
103 |
| - if: ${{ env.RELEASE_VERSION != 'dev' }} |
| 81 | + git config --global user.email [email protected] |
| 82 | + - name: Git refresh tip (detached mode) |
| 83 | + # Git Detached mode (release notes) doesn't have origin |
| 84 | + if: ${{ inputs.detached_mode }} |
| 85 | + run: | |
| 86 | + git config pull.rebase true |
| 87 | + git config remote.origin.url >&- || git remote add origin https://github.com/"$ORIGIN" |
| 88 | + git pull origin "$BRANCH" |
| 89 | + - name: Build docs website and API reference |
| 90 | + run: | |
| 91 | + make release-docs VERSION="$VERSION" ALIAS="$ALIAS" |
| 92 | + poetry run mike set-default --push latest |
| 93 | + - name: Build docs website and API reference |
| 94 | + env: |
| 95 | + VERSION: ${{ inputs.version }} |
| 96 | + ALIAS: ${{ inputs.alias }} |
104 | 97 | run: |
|
105 | 98 | rm -rf site
|
106 | 99 | mkdocs build
|
107 |
| - mike deploy --push --update-aliases --no-redirect "${{ env.RELEASE_VERSION }}" "latest" |
| 100 | + mike deploy --push --update-aliases --no-redirect ${{ env.VERSION }} ${{ env.ALIAS }}" |
108 | 101 | # Set latest version as a default
|
109 | 102 | mike set-default --push latest
|
110 |
| - - name: Publish docs to dev |
111 |
| - if: ${{ env.RELEASE_VERSION == 'dev' }} |
112 |
| - run: | |
113 |
| - rm -rf site |
114 |
| - mkdocs build |
115 |
| - mike deploy --push dev |
116 |
| - - name: Build API docs |
117 |
| - run: | |
118 |
| - rm -rf api |
119 |
| - npm run docs-generateApiDoc |
| 103 | +
|
120 | 104 | - name: Release API docs
|
121 |
| - uses: peaceiris/actions-gh-pages@v3 |
| 105 | + uses: peaceiris/actions-gh-pages@bd8c6b06eba6b3d25d72b7a1767993c0aeee42e7 # v3.9.2 |
| 106 | + env: |
| 107 | + VERSION: ${{ inputs.version }} |
122 | 108 | with:
|
123 | 109 | github_token: ${{ secrets.GITHUB_TOKEN }}
|
124 | 110 | publish_dir: ./api
|
125 | 111 | keep_files: true
|
126 |
| - destination_dir: ${{ env.RELEASE_VERSION }}/api |
127 |
| - - name: Release API docs to latest if isRelease |
128 |
| - if: ${{ env.RELEASE_VERSION != 'dev' }} |
129 |
| - uses: peaceiris/actions-gh-pages@v3 |
| 112 | + destination_dir: ${{ env.VERSION }}/api |
| 113 | + - name: Release API docs to latest |
| 114 | + if: ${{ input.alias == 'latest' }} |
| 115 | + uses: peaceiris/actions-gh-pages@bd8c6b06eba6b3d25d72b7a1767993c0aeee42e7 |
130 | 116 | with:
|
131 | 117 | github_token: ${{ secrets.GITHUB_TOKEN }}
|
132 | 118 | publish_dir: ./api
|
|
0 commit comments