Skip to content

Commit

Permalink
fix delete stacks (#79)
Browse files Browse the repository at this point in the history
## Summary

- Routine Change

### Details

- fixes delete stacks to get correct pull request id
  • Loading branch information
anthony-nhs authored Mar 7, 2024
1 parent 5948642 commit 53ed2d7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions .github/scripts/delete_stacks.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
#!/usr/bin/env bash

ACTIVE_STACKS=$(aws cloudformation list-stacks | jq -r '.StackSummaries[] | select ( .StackStatus != "DELETE_COMPLETE" ) | select( .StackName | capture("^clinical-tracker-pr-(sandbox-)?(\\d+)$") ) | .StackName ')
ACTIVE_STACKS=$(aws cloudformation list-stacks | jq -r '.StackSummaries[] | select ( .StackStatus != "DELETE_COMPLETE" ) | select( .StackName | capture("^clinical-tracker-(sandbox-)?pr-(\\d+)$") ) | .StackName ')

mapfile -t ACTIVE_STACKS_ARRAY <<< "$ACTIVE_STACKS"

for i in "${ACTIVE_STACKS_ARRAY[@]}"
do
echo "Checking if stack $i has open pull request"
PULL_REQUEST=${i//pr-/}
PULL_REQUEST=${PULL_REQUEST//sandbox-/}
PULL_REQUEST=${i//clinical-tracker-pr-/}
PULL_REQUEST=${PULL_REQUEST//clinical-tracker-sandbox-pr-/}
echo "Checking pull request id ${PULL_REQUEST}"
URL="https://api.github.com/repos/NHSDigital/electronic-prescription-service-clinical-prescription-tracker/pulls/${PULL_REQUEST}"

RESPONSE=$(curl "${URL}" 2>/dev/null)
STATE=$(echo "${RESPONSE}" | jq -r .state)
if [ "$STATE" == "closed" ]; then
Expand Down

0 comments on commit 53ed2d7

Please sign in to comment.