Skip to content

Commit cb4883d

Browse files
DPC-5102 Handle error in generate token github action (#2874)
## 🎫 Ticket https://jira.cms.gov/browse/DPC-5102 ## 🛠 Changes Github Action Workflow for generating token validates token before loading into parameter store ## ℹ️ Context We ran this workflow when the API was down, and an html page was entered as the golden macaroon, which made everything else fail. ## 🧪 Validation - Ran the workflow with api up and verified golden macaroon in dev parameter store changed: https://github.com/CMSgov/dpc-app/actions/runs/20664928982 - Ran the workflow with api down and verified the workflow failed and that the token was not updated: https://github.com/CMSgov/dpc-app/actions/runs/20665012110
1 parent ace6791 commit cb4883d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

.github/workflows/generate-macaroon.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ jobs:
4444
- name: Get and load Golden Macaroon
4545
run: |
4646
ALB_URL=$(aws elbv2 describe-load-balancers --names dpc-${{ inputs.env }}-frontend-internal | jq -r '.LoadBalancers[0].DNSName')
47-
token=$(curl -X POST ${ALB_URL}:9900/tasks/generate-token)
48-
aws ssm put-parameter --name '/dpc/${{ inputs.env }}/web/golden_macaroon' --type 'SecureString' --value "${token}" --key-id 'alias/dpc-${{ inputs.env }}-master-key' --overwrite
49-
47+
token=$(curl --fail --silent -X POST ${ALB_URL}:9900/tasks/generate-token)
48+
if [[ -n $token ]]; then
49+
echo $token | base64 -d -i 1>/dev/null && \
50+
aws ssm put-parameter --name '/dpc/${{ inputs.env }}/web/golden_macaroon' --type 'SecureString' --value "${token}" --key-id 'alias/dpc-${{ inputs.env }}-master-key' --overwrite
51+
fi

0 commit comments

Comments
 (0)