1- name : Publish docs
1+ name : Reusable Publish docs
22
33on :
44 workflow_call :
1414 required : false
1515 default : " false"
1616 type : string
17+ versionNumber :
18+ required : false
19+ default : " "
20+ type : string
1721 secrets :
1822 token :
1923 required : true
2024
2125jobs :
2226 publish-docs :
2327 # see https://github.com/awslabs/aws-lambda-powertools-python/issues/1349
24- if : inputs.workflow_origin == 'awslabs/aws-lambda-powertools-typescript'
28+ if : ${{ inputs.workflow_origin == 'awslabs/aws-lambda-powertools-typescript' }}
2529 runs-on : ubuntu-latest
2630 steps :
2731 - name : Checkout code
@@ -56,17 +60,30 @@ jobs:
5660 python-version : " 3.8"
5761 # We run this step only when the workflow has been triggered by a release
5862 # in this case we publish the docs to `/latest`
59- - name : Set RELEASE_VERSION env var to `latest`
63+ - name : (Conditional) Set RELEASE_VERSION env var to `latest`
6064 if : ${{ inputs.isRelease == 'true' }}
6165 run : |
62- RELEASE_VERSION=$(cat packages/commons/package.json | jq '.version' -r)
63- echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV
66+ RELEASE_VERSION=$(echo ${{ github.ref_name }} | sed 's/v//')
67+ EXPLICIT_RELEASE_VERSION=$(echo ${{ inputs.versionNumber }} | sed 's/v//')
68+ if [ $EXPLICIT_RELEASE_VERSION != "" ]; then
69+ echo "RELEASE_VERSION=${EXPLICIT_RELEASE_VERSION}"
70+ echo "RELEASE_VERSION=${EXPLICIT_RELEASE_VERSION}" >> $GITHUB_ENV
71+ else
72+ echo "RELEASE_VERSION=${RELEASE_VERSION}"
73+ echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV
74+ fi
6475 # We run this step only when the workflow has been triggered by a PR merge
6576 # in this case we publish the docs to `/dev`
66- - name : Set RELEASE_VERSION env var to `dev`
77+ - name : (Conditional) Set RELEASE_VERSION env var to `dev`
6778 if : ${{ inputs.prIsMerged == 'true' }}
6879 run : |
6980 echo "RELEASE_VERSION=dev" >> $GITHUB_ENV
81+ - name : Check RELEASE_VERSION env var
82+ if : ${{ env.RELEASE_VERSION == '' }}
83+ uses : actions/github-script@v3
84+ with :
85+ script : |
86+ core.setFailed('RELEASE_VERSION env var is empty.')
7087 - name : Install doc generation dependencies
7188 run : |
7289 pip install --upgrade pip
7592 run : |
7693 git config --global user.name Docs deploy
7794 git config --global user.email docs@dummy.bot.com
78- - name : Publish docs to latest
95+ - name : Publish docs to latest if isRelease
7996 if : ${{ env.RELEASE_VERSION != 'dev' }}
8097 run : |
8198 rm -rf site
@@ -100,3 +117,11 @@ jobs:
100117 publish_dir : ./api
101118 keep_files : true
102119 destination_dir : ${{ env.RELEASE_VERSION }}/api
120+ - name : Release API docs to latest if isRelease
121+ if : ${{ env.RELEASE_VERSION != 'dev' }}
122+ uses : peaceiris/actions-gh-pages@v3
123+ with :
124+ github_token : ${{ secrets.GITHUB_TOKEN }}
125+ publish_dir : ./api
126+ keep_files : true
127+ destination_dir : latest/api
0 commit comments