Skip to content

fix(docs): docs published with incorrect version number + api docs missing after release #1066

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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' }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: why do we need prIsMerged to be true? I thought this workflow is triggerred only when PR merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This workflow is actually triggered by record_pr.yml, which in turn is triggered every time a PR is opened, updated (title or description change), or closed. This is a design that we copied from the Powertools Python repo.

The reason why we don't want to trigger directly is that this workflow is somewhat privileged and we don't want to allow forks to access it. So we trigger the workflow that exports the PR details for most events, and then dispatch the other downstream workflows. Then those workflows can decide what to do based on the content/status of the PR.

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