From 71a0f0b90f491add5987609f2c43cbf5e47a91d2 Mon Sep 17 00:00:00 2001 From: Dan Chevalier Date: Thu, 24 Aug 2023 15:05:48 -0400 Subject: [PATCH] way better validation --- .github/workflows/daily-dev-bump.yaml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/daily-dev-bump.yaml b/.github/workflows/daily-dev-bump.yaml index ee9bb0b71e7..c97dc684d2c 100644 --- a/.github/workflows/daily-dev-bump.yaml +++ b/.github/workflows/daily-dev-bump.yaml @@ -136,15 +136,15 @@ jobs: - name: Clean up branches run: | set -x - # Get 5 most recent branches of closed DartDevtoolWorkflowBot PRs. - # Get list of refs(branches) that exist on the remote + # Get list of refs(branches) that exist on the remote, then filter for the auto-bump branches EXISTING_BRANCHES=$(git ls-remote --heads | grep refs/heads/auto-bump- | sed 's|.*\(auto-bump-[[:digit:]]*\).*|\1|') for EXISTING_BRANCH in $EXISTING_BRANCHES; do - IS_CLOSED=$(gh pr view --json closed --jq '.closed' "$EXISTING_BRANCH") - if [ "$IS_CLOSED" == "true" ] ; then + PR_IS_CLOSED=$(gh pr view --json closed --jq '.closed' "$EXISTING_BRANCH") + PR_AUTHOR=$(gh pr view --json author --jq '.author.login' "$EXISTING_BRANCH") + if [ "$PR_IS_CLOSED" == "true" && "$PR_AUTHOR" == "DartDevtoolWorkflowBot"] ; then # If the branch exists and the PR is closed we will delete it - echo "gh api /repos/flutter/devtools/git/refs/heads/$EXISTING_BRANCH -X DELETE" + gh api /repos/flutter/devtools/git/refs/heads/$EXISTING_BRANCH -X DELETE fi done env: