Skip to content
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
36 changes: 36 additions & 0 deletions .github/workflows/auto-update-prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Auto-update PRs

on:
push:
branches: [main]

# Serialize so two close-together merges don't race the update API.
concurrency:
group: auto-update-prs
cancel-in-progress: false

permissions:
pull-requests: write
contents: write

jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Update PRs labeled 'updateme' to latest main
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
gh pr list --repo "$GITHUB_REPOSITORY" --state open --label updateme --limit 200 \
--json number,isCrossRepository,baseRefName \
--jq '.[] | select(.baseRefName == "main") | "\(.number) \(.isCrossRepository)"' \
| while read -r num is_fork; do
if [ "$is_fork" = "true" ]; then
echo "Skip PR #$num (fork — cannot push via GITHUB_TOKEN)"
continue
fi
echo "Updating PR #$num"
gh pr update-branch "$num" --repo "$GITHUB_REPOSITORY" \
|| echo " -> PR #$num: update-branch failed (see preceding gh output; possible causes: merge conflict, branch protection, transient API error)"
done
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,14 @@ Demonstrates most `get...()` methods.
[Asyncio](https://docs.python.org/3/library/asyncio.html) might seem intimidating in the beginning, but for basic stuff, it is quite easy to follow the examples above, and just remeber to prefix functions that use the API with `async def ...` and to `await` all API-calls and all calls to said functions.

[This article](https://realpython.com/async-io-python/) will give a nice introduction to both why, when and how to use asyncio in projects.

## Contributing

### Keeping a PR up to date with `main`

Add the `updateme` label to a PR targeting `main` and a GitHub Actions workflow will automatically merge `main` into the PR branch every time `main` advances. This is opt-in: PRs without the label are left alone.

Limitations:
- Only acts on PRs whose base branch is `main`. PRs targeting other branches are ignored even with the label.
- Only works for PRs from branches in this repository. PRs from forks cannot be pushed to via the workflow's token and will be skipped (the workflow logs which PRs it skipped).
- If `gh pr update-branch` fails for a given PR (merge conflict, branch protection rule, transient API error, etc.), that PR is skipped for this run and the failure is logged. The label stays on, so the next push to `main` will retry automatically.
Loading