Skip to content
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

fix(docs/ci): change how versions and aliases are inserted into versions.json #1549

Merged
merged 2 commits into from
Jun 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/reusable-publish-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,18 @@ jobs:
# Operations:
# 1. Download the versions.json file from S3
# 2. Find any reference to the alias and delete it from the versions file
# 3. We insert the new version to the versions.json file with the corresponding alias
# 3. This is voodoo (don't use JQ):
# - we assign the input as $o and the new version/alias as $n,
# - we check if the version number exists in the file already (for republishing docs)
# - if it's an alias (stage/latest/*) or old version, we do nothing and output $o (original input)
# - if it's a new version number, we add it at position 0 in the array.
# 4. Once done, we'll upload it back to S3.
run: |
aws s3 cp \
s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-typescript/versions.json \
versions_old.json
jq 'del(.[].aliases[] | select(. == "${{ env.ALIAS }}"))' < versions_old.json > versions_proc.json
jq '. += [{"version": "${{ env.VERSION }}", "title": "${{ env.VERSION }}", "aliases": ["${{ env.ALIAS }}"]}]' < versions_proc.json > versions.json
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
aws s3 cp \
versions.json \
s3://${{ secrets.AWS_DOCS_BUCKET }}/lambda-typescript/versions.json