-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(docs): docs published with incorrect version number + api docs mi…
…ssing after release (#1066)
- Loading branch information
1 parent
bafed02
commit 8b8b25c
Showing
3 changed files
with
57 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Publish docs on release | ||
|
||
on: | ||
# Triggered manually | ||
workflow_dispatch: | ||
inputs: | ||
versionNumber: | ||
required: true | ||
type: string | ||
description: "If running this manually please insert a version number that corresponds to the latest published in the GitHub releases (i.e. v1.1.1)" | ||
# Or triggered as result of a release | ||
release: | ||
types: [released] | ||
|
||
jobs: | ||
publish-docs: | ||
uses: ./.github/workflows/reusable-publish-docs.yml | ||
with: | ||
workflow_origin: ${{ github.event.repository.full_name }} | ||
isRelease: "true" | ||
versionNumber: ${{ inputs.versionNumber }} | ||
secrets: | ||
token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Publish docs | ||
name: Reusable Publish docs | ||
|
||
on: | ||
workflow_call: | ||
|
@@ -14,14 +14,18 @@ on: | |
required: false | ||
default: "false" | ||
type: string | ||
versionNumber: | ||
required: false | ||
default: "" | ||
type: string | ||
secrets: | ||
token: | ||
required: true | ||
|
||
jobs: | ||
publish-docs: | ||
# see https://github.com/awslabs/aws-lambda-powertools-python/issues/1349 | ||
if: inputs.workflow_origin == 'awslabs/aws-lambda-powertools-typescript' | ||
if: ${{ inputs.workflow_origin == 'awslabs/aws-lambda-powertools-typescript' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
|
@@ -56,17 +60,30 @@ jobs: | |
python-version: "3.8" | ||
# We run this step only when the workflow has been triggered by a release | ||
# in this case we publish the docs to `/latest` | ||
- name: Set RELEASE_VERSION env var to `latest` | ||
- name: (Conditional) Set RELEASE_VERSION env var to `latest` | ||
if: ${{ inputs.isRelease == 'true' }} | ||
run: | | ||
RELEASE_VERSION=$(cat packages/commons/package.json | jq '.version' -r) | ||
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV | ||
RELEASE_VERSION=$(echo ${{ github.ref_name }} | sed 's/v//') | ||
EXPLICIT_RELEASE_VERSION=$(echo ${{ inputs.versionNumber }} | sed 's/v//') | ||
if [ $EXPLICIT_RELEASE_VERSION != "" ]; then | ||
echo "RELEASE_VERSION=${EXPLICIT_RELEASE_VERSION}" | ||
echo "RELEASE_VERSION=${EXPLICIT_RELEASE_VERSION}" >> $GITHUB_ENV | ||
else | ||
echo "RELEASE_VERSION=${RELEASE_VERSION}" | ||
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV | ||
fi | ||
# We run this step only when the workflow has been triggered by a PR merge | ||
# in this case we publish the docs to `/dev` | ||
- name: Set RELEASE_VERSION env var to `dev` | ||
- name: (Conditional) Set RELEASE_VERSION env var to `dev` | ||
if: ${{ inputs.prIsMerged == 'true' }} | ||
run: | | ||
echo "RELEASE_VERSION=dev" >> $GITHUB_ENV | ||
- name: Check RELEASE_VERSION env var | ||
if: ${{ env.RELEASE_VERSION == '' }} | ||
uses: actions/github-script@v3 | ||
with: | ||
script: | | ||
core.setFailed('RELEASE_VERSION env var is empty.') | ||
- name: Install doc generation dependencies | ||
run: | | ||
pip install --upgrade pip | ||
|
@@ -75,7 +92,7 @@ jobs: | |
run: | | ||
git config --global user.name Docs deploy | ||
git config --global user.email [email protected] | ||
- name: Publish docs to latest | ||
- name: Publish docs to latest if isRelease | ||
if: ${{ env.RELEASE_VERSION != 'dev' }} | ||
run: | | ||
rm -rf site | ||
|
@@ -100,3 +117,11 @@ jobs: | |
publish_dir: ./api | ||
keep_files: true | ||
destination_dir: ${{ env.RELEASE_VERSION }}/api | ||
- name: Release API docs to latest if isRelease | ||
if: ${{ env.RELEASE_VERSION != 'dev' }} | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./api | ||
keep_files: true | ||
destination_dir: latest/api |