Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 4 additions & 3 deletions .semaphore/production-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ blocks:
commands:
- artifact pull workflow clevertap.min.js
- |
set -euo pipefail
mkdir utils
aws s3 cp s3://cfstack-init-sources3bucket-b5bxfzywj4ae/utils/generate_assumed_role_creds.py utils/generate_assumed_role_creds.py
eval $(python3 utils/generate_assumed_role_creds.py --role-arn ${PRODUCTION_ACCOUNT_IAM_ROLE_ARN} --session-name SemaphoreAgent)
env | grep AWS
aws sts get-caller-identity
- 'aws s3 cp clevertap.min.js s3://static.wizrocket.com/js/ --acl public-read'
- rm -r clevertap.min.js
- aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths /js/clevertap.min.js
aws s3 cp clevertap.min.js s3://static.wizrocket.com/js/ --acl public-read
rm -r clevertap.min.js
aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths /js/clevertap.min.js
Comment on lines +15 to +23
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

⚠️ Potential issue

Strict mode added: good, but current script will leak AWS secrets and may fail due to pipefail.

  • env | grep AWS will print creds to logs and, with set -euo pipefail, can fail the job if grep returns 1. Remove it.
  • Use rm -f instead of rm -r for single files to avoid unnecessary failure under -e.

Apply:

-              set -euo pipefail
+              set -euo pipefail
               mkdir utils
               aws s3 cp s3://cfstack-init-sources3bucket-b5bxfzywj4ae/utils/generate_assumed_role_creds.py utils/generate_assumed_role_creds.py
               eval $(python3 utils/generate_assumed_role_creds.py --role-arn ${PRODUCTION_ACCOUNT_IAM_ROLE_ARN} --session-name SemaphoreAgent)
-              env | grep AWS
               aws sts get-caller-identity
               aws s3 cp clevertap.min.js s3://static.wizrocket.com/js/ --acl public-read
-              rm -r clevertap.min.js
+              rm -f -- clevertap.min.js
               aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths /js/clevertap.min.js
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
set -euo pipefail
mkdir utils
aws s3 cp s3://cfstack-init-sources3bucket-b5bxfzywj4ae/utils/generate_assumed_role_creds.py utils/generate_assumed_role_creds.py
eval $(python3 utils/generate_assumed_role_creds.py --role-arn ${PRODUCTION_ACCOUNT_IAM_ROLE_ARN} --session-name SemaphoreAgent)
env | grep AWS
aws sts get-caller-identity
- 'aws s3 cp clevertap.min.js s3://static.wizrocket.com/js/ --acl public-read'
- rm -r clevertap.min.js
- aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths /js/clevertap.min.js
aws s3 cp clevertap.min.js s3://static.wizrocket.com/js/ --acl public-read
rm -r clevertap.min.js
aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths /js/clevertap.min.js
set -euo pipefail
mkdir utils
aws s3 cp s3://cfstack-init-sources3bucket-b5bxfzywj4ae/utils/generate_assumed_role_creds.py utils/generate_assumed_role_creds.py
eval $(python3 utils/generate_assumed_role_creds.py --role-arn ${PRODUCTION_ACCOUNT_IAM_ROLE_ARN} --session-name SemaphoreAgent)
aws sts get-caller-identity
aws s3 cp clevertap.min.js s3://static.wizrocket.com/js/ --acl public-read
rm -f -- clevertap.min.js
aws cloudfront create-invalidation --distribution-id E1OCAMMKX0F1A1 --paths /js/clevertap.min.js
🤖 Prompt for AI Agents
In .semaphore/production-deploy.yml around lines 15 to 23, remove the line that
prints environment variables with "env | grep AWS" (it can leak credentials and
under set -euo pipefail a non-zero grep exit will fail the job) and replace the
"rm -r clevertap.min.js" with "rm -f clevertap.min.js" so removing the file
won't error under strict mode.

secrets:
- name: ProductionAccountAwsCredentials
agent:
Expand Down
6 changes: 4 additions & 2 deletions .semaphore/semaphore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ blocks:
- artifact push workflow clevertap.min.js
- artifact push workflow clevertap.js
- artifact push workflow clevertap.js.map
- npm install
- npm run build_sw
- |
set -euo pipefail
npm install
npm run build_sw
- artifact push workflow sw_webpush.min.js
- artifact push workflow sw_webpush.js
promotions:
Expand Down
1 change: 1 addition & 0 deletions .semaphore/staging-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ blocks:
- artifact pull workflow sw_webpush.js
- artifact pull workflow sw_webpush.min.js
- |
set -euo pipefail
mkdir utils
aws s3 cp s3://cfstack-init-sources3bucket-b5bxfzywj4ae/utils/generate_assumed_role_creds.py utils/generate_assumed_role_creds.py
eval $(python3 utils/generate_assumed_role_creds.py --role-arn ${PRODUCTION_ACCOUNT_IAM_ROLE_ARN} --session-name SemaphoreAgent)
Expand Down
Loading