diff --git a/.github/workflows/auto-merge-generated-prs.yml b/.github/workflows/auto-merge-generated-prs.yml new file mode 100644 index 00000000..16eff237 --- /dev/null +++ b/.github/workflows/auto-merge-generated-prs.yml @@ -0,0 +1,37 @@ +name: Auto-merge generated SDK PRs + +on: + pull_request: + types: [opened, reopened, synchronize, labeled, ready_for_review] + +permissions: + contents: write + pull-requests: write + +jobs: + enable-automerge: + if: > + (github.event.pull_request.user.login == 'github-actions' || + github.event.pull_request.user.login == 'github-actions[bot]') && + startsWith(github.event.pull_request.title, 'chore: 🐝 Update SDK - Generate') + runs-on: ubuntu-latest + steps: + - name: Check labels (needs minor or patch) + id: labels + uses: actions/github-script@v7 + with: + script: | + const { owner, repo } = context.repo; + const prNumber = context.payload.pull_request.number; + const { data: labels } = await github.rest.issues.listLabelsOnIssue({ owner, repo, issue_number: prNumber }); + const names = labels.map(l => l.name.toLowerCase()); + core.setOutput('match', names.includes('minor') || names.includes('patch')); + + - name: Enable auto-merge (squash) + if: steps.labels.outputs.match == 'true' + uses: peter-evans/enable-pull-request-automerge@v3 + with: + pull-request-number: ${{ github.event.pull_request.number }} + merge-method: squash + token: ${{ secrets.GITHUB_TOKEN }} +