Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: [AEA-4654] - fix delete stacks #144

Merged
merged 6 commits into from
Nov 4, 2024
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
8 changes: 2 additions & 6 deletions .github/scripts/delete_stacks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
REPO_NAME=eps-prescription-tracker-ui

# this should be a regex used in jq command that parses the output from aws cloudformation list-stacks and just captures stacks we are interested in
CAPTURE_REGEX="^cpt-ui-(sandbox-)?pr-(\\d+)$"

# this should be a regex that is used to get the pull request id from the cloud formation stack name
# this is used in a replace command to replace the stack name so what is left is just the pull request id
PULL_REQUEST_STACK_REGEX=cpt-ui-pr-
CAPTURE_REGEX="^cpt-ui-pr-(\\d+)-*"

CNAME_QUERY=cpt-ui-pr

Expand Down Expand Up @@ -38,7 +34,7 @@ delete_cloudformation_stacks() {
for i in "${ACTIVE_STACKS_ARRAY[@]}"
do
echo "Checking if stack $i has open pull request"
PULL_REQUEST=${i//${PULL_REQUEST_STACK_REGEX}/}
PULL_REQUEST=$(echo "$i" | grep -oP '\d+')
echo "Checking pull request id ${PULL_REQUEST}"
URL="https://api.github.com/repos/NHSDigital/${REPO_NAME}/pulls/${PULL_REQUEST}"
RESPONSE=$(curl --url "${URL}" --header "Authorization: Bearer ${GITHUB_TOKEN}" 2>/dev/null)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/delete_old_cloudformation_stacks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: 'Delete old cloudformation stacks'
on:
workflow_dispatch:
schedule:
- cron: "0 2,14 * * *"
- cron: "20 * * * *"

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Expand Down