Skip to content
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

feat: close previous update PRs when a new one is generated #142

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,34 @@ 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
rriski marked this conversation as resolved.
Show resolved Hide resolved
- 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
- uses: peter-evans/create-pull-request@v7
- id: create_pr
uses: peter-evans/create-pull-request@v7
with:
author: GitHub <noreply@github.com>
body: >
automated changes by
[update](https://github.com/aiven/go-client-codegen/blob/main/.github/workflows/update.yml)
GitHub Actions workflow
branch: update/${{ steps.date.outputs.date }}
branch: update/${{ steps.date.outputs.date }}-${{ github.run_id }}
commit-message: "chore(update): bump openapi schema (${{ steps.date.outputs.date }})"
title: "chore(update): bump openapi schema (${{ steps.date.outputs.date }})"
labels: |
schema bump
automated pr
- name: Close previous update PRs
run: |
new_pr_number=${{ steps.create_pr.outputs.pull-request-number }}
prs=$(gh pr list --state open --json number,headRefName --jq '.[] | select(.headRefName | startswith("update/")) | .number')
for pr in $prs; do
if [ "$pr" != "$new_pr_number" ]; then
gh pr close $pr --comment "Auto-closing pull request in favor of #$new_pr_number" --delete-branch
fi
done
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading