1
- name : Publish docs
1
+ name : Reusable Publish docs
2
2
3
3
on :
4
4
workflow_call :
14
14
required : false
15
15
default : " false"
16
16
type : string
17
+ versionNumber :
18
+ required : false
19
+ default : " "
20
+ type : string
17
21
secrets :
18
22
token :
19
23
required : true
20
24
21
25
jobs :
22
26
publish-docs :
23
27
# 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' }}
25
29
runs-on : ubuntu-latest
26
30
steps :
27
31
- name : Checkout code
@@ -56,17 +60,30 @@ jobs:
56
60
python-version : " 3.8"
57
61
# We run this step only when the workflow has been triggered by a release
58
62
# 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`
60
64
if : ${{ inputs.isRelease == 'true' }}
61
65
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
64
75
# We run this step only when the workflow has been triggered by a PR merge
65
76
# 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`
67
78
if : ${{ inputs.prIsMerged == 'true' }}
68
79
run : |
69
80
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.')
70
87
- name : Install doc generation dependencies
71
88
run : |
72
89
pip install --upgrade pip
75
92
run : |
76
93
git config --global user.name Docs deploy
77
94
git config --global user.email [email protected]
78
- - name : Publish docs to latest
95
+ - name : Publish docs to latest if isRelease
79
96
if : ${{ env.RELEASE_VERSION != 'dev' }}
80
97
run : |
81
98
rm -rf site
@@ -100,3 +117,11 @@ jobs:
100
117
publish_dir : ./api
101
118
keep_files : true
102
119
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