Skip to content

Commit

Permalink
fix(docs): docs published with incorrect version number + api docs mi…
Browse files Browse the repository at this point in the history
…ssing after release (#1066)
  • Loading branch information
dreamorosi authored Aug 23, 2022
1 parent bafed02 commit 8b8b25c
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/on-merge-to-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
run-unit-tests:
needs: get_pr_details
if: ${{ needs.get_pr_details.outputs.prIsMerged == 'true' }}
uses: ./.github/workflows/reusable-run-unit-tests.yml
publish:
needs:
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/publish-docs-on-release.yml
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 }}
39 changes: 32 additions & 7 deletions .github/workflows/reusable-publish-docs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish docs
name: Reusable Publish docs

on:
workflow_call:
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

0 comments on commit 8b8b25c

Please sign in to comment.