1
- # Build Docs
1
+ # Build Latest Docs
2
2
#
3
3
# Description:
4
- # Builds the docs and stores them in S3 to be served by our docs platform
4
+ # Builds the latest docs and stores them in S3 to be served by our docs platform
5
5
#
6
6
# The workflow allows us to build to the main location (/lambda/java/) and to an alias
7
7
# (i.e. /lambda/java/preview/) if needed
15
15
on :
16
16
workflow_dispatch :
17
17
inputs :
18
- alias :
18
+ version :
19
+ description : " Version to build and publish docs (1.28.0, develop)"
20
+ required : true
19
21
type : string
20
- required : false
21
- description : |
22
- Alias to deploy the documentation into, this is mostly for testing pre-release
23
- versions of the documentation, such as beta versions or snapshots.
24
22
25
- https://docs.powertools.aws.dev/lambda/java/<alias>
26
-
27
- name : Build Docs
28
- run-name : Build Docs - ${{ contains(github.head_ref, 'main') && 'main' || inputs.alias }}
23
+ name : Build Latest Docs
24
+ run-name : Build Latest Docs - ${{ inputs.version }}
29
25
30
26
permissions :
31
27
contents : read
@@ -38,28 +34,58 @@ jobs:
38
34
id-token : write
39
35
environment : Docs
40
36
steps :
41
- - name : Sanity Check
42
- if : ${{ github.head_ref != 'main' || inputs.alias == '' }}
43
- run :
44
- echo "::error::No buildable docs"
45
-
46
37
- name : Checkout Repository
47
38
uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
48
- with :
39
+ with :
49
40
fetch-depth : 0
50
41
- name : Build
51
42
run : |
52
43
mkdir -p dist
53
44
docker build -t squidfunk/mkdocs-material ./docs/
54
45
docker run --rm -t -v ${PWD}:/docs squidfunk/mkdocs-material build
55
- cp -R site/* dist/
56
46
- name : Configure AWS credentials
57
47
uses : aws-actions/configure-aws-credentials@ececac1a45f3b08a01d2dd070d28d111c5fe6722
58
48
with :
59
49
aws-region : us-east-1
60
50
role-to-assume : ${{ secrets.AWS_DOCS_ROLE_ARN }}
61
- - name : Deploy
51
+ - name : Deploy Docs (Version)
52
+ env :
53
+ VERSION : ${{ inputs.version }}
54
+ ALIAS : " latest"
62
55
run : |
63
56
aws s3 sync \
64
- dist \
65
- s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-java/${{ github.head_ref == 'main' && '' || format('{0}/', inputs.alias )}}
57
+ site/ \
58
+ s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-java/${{ env.VERSION }}/
59
+ - name : Deploy Docs (Alias)
60
+ env :
61
+ VERSION : ${{ inputs.version }}
62
+ ALIAS : " latest"
63
+ run : |
64
+ aws s3 sync \
65
+ site/ \
66
+ s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-java/${{ env.ALIAS }}/
67
+ - name : Deploy Docs (Version JSON)
68
+ env :
69
+ VERSION : ${{ inputs.version }}
70
+ ALIAS : " latest"
71
+ # We originally used "mike" from PyPi to manage versions for us, but since we moved to S3, we can't use it to manage versions any more.
72
+ # Instead, we're using some shell script that manages the versions.
73
+ #
74
+ # Operations:
75
+ # 1. Download the versions.json file from S3
76
+ # 2. Find any reference to the alias and delete it from the versions file
77
+ # 3. This is voodoo (don't use JQ):
78
+ # - we assign the input as $o and the new version/alias as $n,
79
+ # - we check if the version number exists in the file already (for republishing docs)
80
+ # - if it's an alias (stage/latest/*) or old version, we do nothing and output $o (original input)
81
+ # - if it's a new version number, we add it at position 0 in the array.
82
+ # 4. Once done, we'll upload it back to S3.
83
+ run : |
84
+ aws s3 cp \
85
+ s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-java/versions.json \
86
+ versions_old.json
87
+ jq 'del(.[].aliases[] | select(. == "${{ env.ALIAS }}"))' < versions_old.json > versions_proc.json
88
+ jq '. as $o | [{"title": "${{ env.VERSION }}", "version": "${{ env.VERSION }}", "aliases": ["${{ env.ALIAS }}"] }] as $n | $n | if .[0].title | test("[a-z]+") or any($o[].title == $n[0].title;.) then [($o | .[] | select(.title == $n[0].title).aliases += $n[0].aliases | . )] else $n + $o end' < versions_proc.json > versions.json
89
+ aws s3 cp \
90
+ versions.json \
91
+ s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-java/versions.json
0 commit comments