Skip to content

Commit

Permalink
ci: prevent s3 files being overwritten
Browse files Browse the repository at this point in the history
If a released binary has been uploaded to S3, it should be prevented from being overwritten. If it
is being overwritten, it could very well be suggestive of a mistake somewhere. If you really want to
intentionally overwrite the file for some reason, remove it from the S3 bucket manually, then run
the workflow again.
  • Loading branch information
jacderida committed Jul 4, 2024
1 parent 01ee874 commit 9d9214f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,14 @@ upload-release-assets-to-s3 bin_name:

cd deploy/{{bin_name}}
for file in *.zip *.tar.gz; do
aws s3 cp "$file" "s3://$bucket/$file" --acl public-read
dest="s3://$bucket/$file"
if aws s3 ls "$dest" > /dev/null 2>&1; then
echo "$dest already exists. This suggests an error somewhere."
echo "If you intentionally want to overwrite, remove the file and run the workflow again."
exit 1
else
aws s3 cp "$file" "$dest" --acl public-read
fi
done

node-man-integration-tests:
Expand Down
12 changes: 12 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

BUCKET_NAME="your-bucket-name"
DESTINATION_PATH="s3://nat-detection/nat-detection-0.1.0-aarch64-unknown-linux-musl.zip"
LOCAL_FILE_PATH="path/to/local/file"

if aws s3 ls "$DESTINATION_PATH" > /dev/null 2>&1; then
echo "Error: Destination file already exists in the bucket."
exit 1
else
echo "will upload"
fi

0 comments on commit 9d9214f

Please sign in to comment.