Skip to content

Commit

Permalink
add GitHub workflow to run sanitizer script automatically (#1294)
Browse files Browse the repository at this point in the history
  • Loading branch information
sastels authored May 2, 2024
1 parent 1dd74ae commit 98725ef
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 2 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/sanitize_production_sms_usage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Sanitize production SMS usage data
on:
workflow_dispatch:
schedule:
- cron: "0 22 * * *"

env:
INPUT_BUCKET_1: notification-canada-ca-production-sms-usage-logs
INPUT_BUCKET_2: notification-canada-ca-production-sms-usage-west-2-logs

jobs:
sanitize-sms-usage:
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
with:
aws-access-key-id: ${{ secrets.PRODUCTION_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.PRODUCTION_AWS_SECRET_ACCESS_KEY }}
aws-region: ca-central-1

- name: run script
run: |
./scripts/sanitize_sms_usage_logs.sh ${INPUT_BUCKET_1} ${INPUT_BUCKET_1}-san
./scripts/sanitize_sms_usage_logs.sh ${INPUT_BUCKET_2} ${INPUT_BUCKET_2}-san
- name: Notify Slack channel if this job failed
if: ${{ failure() }}
run: |
json="{'text':'<!here> Sanitize production SMS usage data failed in <https://github.com/cds-snc/notification-terraform/|notification-terraform> !'}"
curl -X POST -H 'Content-type: application/json' --data "$json" ${{ secrets.NOTIFY_DEV_SLACK_WEBHOOK }}
35 changes: 35 additions & 0 deletions .github/workflows/sanitize_staging_sms_usage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Sanitize staging SMS usage data
on:
workflow_dispatch:
schedule:
- cron: "0 22 * * *"

env:
INPUT_BUCKET_1: notification-canada-ca-staging-sms-usage-logs
INPUT_BUCKET_2: notification-canada-ca-staging-sms-usage-west-2-logs

jobs:
sanitize-sms-usage:
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
with:
aws-access-key-id: ${{ secrets.STAGING_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.STAGING_AWS_SECRET_ACCESS_KEY }}
aws-region: ca-central-1

- name: run script
run: |
./scripts/sanitize_sms_usage_logs.sh ${INPUT_BUCKET_1} ${INPUT_BUCKET_1}-san
./scripts/sanitize_sms_usage_logs.sh ${INPUT_BUCKET_2} ${INPUT_BUCKET_2}-san
- name: Notify Slack channel if this job failed
if: ${{ failure() }}
run: |
json="{'text':'<!here> Sanitize staging SMS usage data failed in <https://github.com/cds-snc/notification-terraform/|notification-terraform> !'}"
curl -X POST -H 'Content-type: application/json' --data "$json" ${{ secrets.NOTIFY_DEV_SLACK_WEBHOOK }}
4 changes: 2 additions & 2 deletions scripts/sanitize_sms_usage_logs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ for file in $(echo $objects | jq -r '.[]'); do
gzip $csvFile
aws s3 cp $file s3://$outbucket/$file --content-encoding gzip
rm $file
fi
done
fi
done

0 comments on commit 98725ef

Please sign in to comment.