From fc32bf2be5cda3aa88219c95c39da3c94dd6b98d Mon Sep 17 00:00:00 2001 From: Timo Riski Date: Wed, 25 Sep 2024 10:18:39 +0300 Subject: [PATCH] feat: close previous update PRs when a new one is generated --- .github/workflows/update.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 290e023..c13c299 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -22,13 +22,20 @@ jobs: go-version-file: go.mod - run: go install golang.org/x/tools/cmd/goimports@latest - uses: arduino/setup-task@v2 - - run: wget -O openapi.json https://api.aiven.io/doc/openapi.json - run: task generate env: AIVEN_TOKEN: ${{ secrets.AIVEN_TOKEN }} AIVEN_PROJECT_NAME: ${{ secrets.AIVEN_PROJECT_NAME }} - id: date run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT + - name: Close previous update PRs + run: | + prs=$(gh pr list --state open --json number,headRefName --jq '.[] | select(.headRefName | startswith("update/")) | .number') + for pr in $prs; do + gh pr close $pr --comment "Auto-closing pull request" --delete-branch + done + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - uses: peter-evans/create-pull-request@v7 with: author: GitHub @@ -36,6 +43,9 @@ jobs: automated changes by [update](https://github.com/aiven/go-client-codegen/blob/main/.github/workflows/update.yml) GitHub Actions workflow + labels: | + schema bump + automated pr branch: update/${{ steps.date.outputs.date }} commit-message: "chore(update): bump openapi schema (${{ steps.date.outputs.date }})" title: "chore(update): bump openapi schema (${{ steps.date.outputs.date }})"