Skip to content

Commit

Permalink
Add check if list exist already on s3
Browse files Browse the repository at this point in the history
  • Loading branch information
chrstph-dvx committed Jan 2, 2024
1 parent fb62fc1 commit 1c02602
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions .github/workflows/generate-token-lists.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,25 +145,22 @@ jobs:
if: success()
run: ${{ matrix.commands.command }}

- name: Get online version
id: onlineVersion
if: ${{ matrix.commands.version == true && matrix.commands.version == true }}
- name: Check if online list exist
id: listExist
run: |
version=$(curl https://tokenlist.arbitrum.io/${{ matrix.commands.paths[0] }} | jq .version | jq 'join(".")')
if [[ -n $version ]]; then
echo "onlineVersion=$version" >> $GITHUB_OUTPUT
if aws s3api head-object --bucket ${{ secrets.AWS_BUCKET }} --key ${{ matrix.commands.paths[0] }}
echo "listExist=true" >> $GITHUB_OUTPUT
else
# Make sure failure from curl or jq fails the generation
exit 1
echo "listExist=false" >> $GITHUB_OUTPUT
fi
- name: Get new version
id: newVersion
if: ${{ matrix.commands.version == true && matrix.commands.version == true }}
- name: Get online version
id: onlineVersion
if: ${{ matrix.commands.version == true && matrix.commands.version == true && steps.listExist.outputs.listExist == 'true' }}
run: |
version=$(cat ./src/${{ matrix.commands.paths[0] }} | jq .version | jq 'join(".")')
version=$(curl https://tokenlist.arbitrum.io/${{ matrix.commands.paths[0] }} | jq .version | jq 'join(".")')
if [[ -n $version ]]; then
echo "newVersion=$version" >> $GITHUB_OUTPUT
echo "onlineVersion=$version" >> $GITHUB_OUTPUT
else
# Make sure failure from curl or jq fails the generation
exit 1
Expand All @@ -175,20 +172,24 @@ jobs:
paths=(${{ join(matrix.commands.paths, ' ') }})
for path in ${paths[*]}
do
aws s3 cp s3://${{ secrets.AWS_BUCKET }}/TestFolder/$path s3://${{ secrets.AWS_BUCKET }}/TestFolder/${{ steps.onlineVersion.outputs.onlineVersion }}/
if aws s3 ls s3://${{ secrets.AWS_BUCKET }}/TestFolder/$path | wc -l
aws s3 cp s3://${{ secrets.AWS_BUCKET }}/TestFolder/$path s3://${{ secrets.AWS_BUCKET }}/TestFolder/${{ steps.onlineVersion.outputs.onlineVersion }}/
fi
done
- name: Deploy (Test folder)
if: ${{ inputs.environment == 'Test' }}
run: aws s3 sync ./src/ s3://${{ secrets.AWS_BUCKET }}/TestFolder --exclude "*" --include "FullList/*.json" --include "ArbTokenLists/*.json"

- name: Backup
if: ${{ inputs.environment == 'CI' && matrix.commands.version == true }}
if: ${{ inputs.environment == 'CI' && matrix.commands.version == true && steps.listExist.outputs.listExist == 'true' }}
run: |
paths=(${{ join(matrix.commands.paths, ' ') }})
for path in ${paths[*]}
do
aws s3 cp s3://${{ secrets.AWS_BUCKET }}/$path s3://${{ secrets.AWS_BUCKET }}/${{ steps.onlineVersion.outputs.onlineVersion }}/
if aws s3 ls s3://${{ secrets.AWS_BUCKET }}/$path | wc -l
aws s3 cp s3://${{ secrets.AWS_BUCKET }}/$path s3://${{ secrets.AWS_BUCKET }}/${{ steps.onlineVersion.outputs.onlineVersion }}/
fi
done
- name: Deploy
Expand Down

0 comments on commit 1c02602

Please sign in to comment.