diff --git a/.github/workflows/generate-token-lists.yml b/.github/workflows/generate-token-lists.yml index 02e754a5..3833c37b 100644 --- a/.github/workflows/generate-token-lists.yml +++ b/.github/workflows/generate-token-lists.yml @@ -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 @@ -175,7 +172,9 @@ 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) @@ -183,12 +182,14 @@ jobs: 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