-
Notifications
You must be signed in to change notification settings - Fork 5
bin/orphaned-pr-environments: Handle no PR envs and merged PRs better #889
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,8 @@ | |
| # ----------------------------------------------------------------------------- | ||
| set -euo pipefail | ||
|
|
||
| GITHUB_STEP_SUMMARY=${GITHUB_STEP_SUMMARY:-/dev/null} | ||
|
|
||
| app_name="$1" | ||
|
|
||
| echo "::group::Initialize Terraform" | ||
|
|
@@ -17,7 +19,9 @@ echo "::endgroup::" | |
| echo "::group::List PRs with PR environments" | ||
| echo terraform -chdir="infra/${app_name}/service" workspace list | ||
| workspaces="$(terraform -chdir="infra/${app_name}/service" workspace list)" | ||
| pr_nums="$(echo "${workspaces}" | grep -o 'p-[0-9]\+' | sed 's/p-//')" | ||
| # grep will exit with code `1` if there's no match, so ignore that for when | ||
| # there are no PR workspaces for the application | ||
| pr_nums="$(echo "${workspaces}" | { grep -o 'p-[0-9]\+' || test $? = 1; } | sed 's/p-//')" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we add a comment like also, can you help me understand the advantage of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah ok that makes sense, thanks |
||
| echo "PRs" | ||
| echo "${pr_nums}" | ||
| echo "::endgroup::" | ||
|
|
@@ -28,7 +32,7 @@ for pr_num in $pr_nums; do | |
| pr_status="$(gh pr view "$pr_num" --json state --jq ".state")" | ||
| echo "PR ${pr_num}: ${pr_status}" | ||
|
|
||
| if [ "$pr_status" == "CLOSED" ]; then | ||
| if [ "$pr_status" == "CLOSED" ] || [ "$pr_status" == "MERGED" ]; then | ||
doshitan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| closed_prs+=("$pr_num") | ||
| fi | ||
| done | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.