-
Notifications
You must be signed in to change notification settings - Fork 154
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
dreamorosi
merged 6 commits into
main
from
1063-bug-docs-incorrect-version-number-in-the-docs-+-api-docs-returning-404
Aug 23, 2022
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b00b799
fix: re-add release API docs to latest
dreamorosi 75497ef
fix: added additional guard + explicit names
dreamorosi b653c13
fix: made docs publish trigger on release
dreamorosi dbb1e3e
fix: added manual run publish docs
dreamorosi 67fd073
fix: make sure reusable-publish-docs runs only when merged
dreamorosi d43dda0
Update .github/workflows/publish-docs-on-release.yml
dreamorosi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.There was a problem hiding this comment.
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.