Skip to content

Commit 9e1d19a

Browse files
authoredJun 23, 2023
fix(ci): change how versions and aliases are inserted into versions.json (#1549)
* Update reusable-publish-docs.yml * remove .
1 parent 58b0877 commit 9e1d19a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed
 

‎.github/workflows/reusable-publish-docs.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,18 @@ jobs:
136136
# Operations:
137137
# 1. Download the versions.json file from S3
138138
# 2. Find any reference to the alias and delete it from the versions file
139-
# 3. We insert the new version to the versions.json file with the corresponding alias
139+
# 3. This is voodoo (don't use JQ):
140+
# - we assign the input as $o and the new version/alias as $n,
141+
# - we check if the version number exists in the file already (for republishing docs)
142+
# - if it's an alias (stage/latest/*) or old version, we do nothing and output $o (original input)
143+
# - if it's a new version number, we add it at position 0 in the array.
140144
# 4. Once done, we'll upload it back to S3.
141145
run: |
142146
aws s3 cp \
143147
s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-typescript/versions.json \
144148
versions_old.json
145149
jq 'del(.[].aliases[] | select(. == "${{ env.ALIAS }}"))' < versions_old.json > versions_proc.json
146-
jq '. += [{"version": "${{ env.VERSION }}", "title": "${{ env.VERSION }}", "aliases": ["${{ env.ALIAS }}"]}]' < versions_proc.json > versions.json
150+
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 == "${{ env.VERSION }}";.) then $o else $n + $o end' < versions_proc.json > versions.json
147151
aws s3 cp \
148152
versions.json \
149153
s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-typescript/versions.json

0 commit comments

Comments
 (0)
Please sign in to comment.