Skip to content

Commit

Permalink
Don't comment on PR after destroying PR environment (#674)
Browse files Browse the repository at this point in the history
The PR environment destroyed comment is also noisy since it
sends an email notification and it's never actionable.
  • Loading branch information
lorenyu authored Jun 29, 2024
1 parent 46949a5 commit c742e5e
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions bin/destroy-pr-environment
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,21 @@ terraform -chdir="infra/${app_name}/service" workspace select default
echo "Delete workspace: ${workspace}"
terraform -chdir="infra/${app_name}/service" workspace delete "${workspace}"

echo "Post comment to PR confirming environment destruction"
gh pr comment "${pr_number}" -b "Destroyed PR environment"
pr_info=$(cat <<EOF
<!-- begin PR environment info -->
## Preview environment
Environment destroyed
<!-- end PR environment info -->
EOF
)

pr_body="$(gh pr view "${pr_number}" --json body | jq --raw-output .body)"
if [[ $pr_body == *"<!-- begin PR environment info -->"*"<!-- end PR environment info -->"* ]]; then
pr_body="${pr_body//<!-- begin PR environment info -->*<!-- end PR environment info -->/$pr_info}"
else
pr_body="${pr_body}"$'\n\n'"${pr_info}"
fi

echo "Update PR description with PR environment info"
echo "${pr_info}"
gh pr edit "${pr_number}" --body "${pr_body}"

0 comments on commit c742e5e

Please sign in to comment.