Skip to content

Automatically label PRs to sync and auto-merge #822

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

Merged
merged 6 commits into from
Jun 11, 2025
Merged
Show file tree
Hide file tree
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
26 changes: 26 additions & 0 deletions .github/workflows/pr-auto-label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "Automatically mark PRs to sync"

on:
pull_request:
types:
- opened

jobs:
labeler:
if: github.event.pull_request.user.type != 'Bot'
permissions:
pull-requests: write

runs-on: ubuntu-latest
steps:
- name: Add "sync" label to PR
run: gh pr edit "$PR_URL" --add-label sync
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_URL: ${{ github.event.pull_request.html_url }}

- name: Comment on PR to explain sync label
run: gh pr comment "$PR_URL" --body "This pull request has been marked to **automatically sync** to its base branch. You can **disable** this behavior by removing the `sync` label."
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_URL: ${{ github.event.pull_request.html_url }}
23 changes: 23 additions & 0 deletions .github/workflows/pr-auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: "Automatically enable auto-merge on PRs"

on:
pull_request_target:
types:
- opened
- ready_for_review
branches:
- main

jobs:
enable-automerge:
if: github.event.pull_request.draft == false
permissions:
pull-requests: write

runs-on: ubuntu-latest
steps:
- name: Enable auto-merge for the PR
run: gh pr merge "$PR_URL" --auto --squash
env:
GH_TOKEN: ${{ secrets.PR_AUTO_UPDATE_TOKEN }}
PR_URL: ${{ github.event.pull_request.html_url }}
Loading