From fdf994dc35b72ce2ed6b737e882acc4e4a3733a0 Mon Sep 17 00:00:00 2001 From: Guilherme Macedo Date: Mon, 3 Apr 2023 15:40:49 -0300 Subject: [PATCH] [UpdateCLI] Improve workflow (#7142) * Improve UpdateCLI workflow * Update Go version to stable in workflow Signed-off-by: Guilherme Macedo --- .github/workflows/updatecli.yaml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/updatecli.yaml b/.github/workflows/updatecli.yaml index a0c381841e..26773bb694 100644 --- a/.github/workflows/updatecli.yaml +++ b/.github/workflows/updatecli.yaml @@ -25,7 +25,15 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: '1.19.6' + go-version: 'stable' + + - name: Delete leftover UpdateCLI branches + run: | + gh pr list --search "is:closed is:pr head:updatecli_" --json headRefName --jq ".[].headRefName" | sort -u > closed_prs_branches.txt + gh pr list --search "is:open is:pr head:updatecli_" --json headRefName --jq ".[].headRefName" | sort -u > open_prs_branches.txt + for branch in $(comm -23 closed_prs_branches.txt open_prs_branches.txt); do if (git ls-remote --exit-code --heads origin "$branch"); then echo "Deleting leftover UpdateCLI branch - $branch"; git push origin --delete "$branch"; fi done + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Install Updatecli uses: updatecli/updatecli-action@v2