Skip to content

Auto-update PR branches on push to main #3

Auto-update PR branches on push to main

Auto-update PR branches on push to main #3

name: Auto-update PR branches
run-name: Auto-update PR branches on push to main
on:
push:
branches:
- main
permissions:
contents: write
pull-requests: write
jobs:
update-branches:
runs-on: ubuntu-latest
if: github.repository == 'maansaake/locksmith'
steps:
- name: Generate GitHub App token
id: app-token
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
with:
client-id: ${{ secrets.JEEVES_APP_ID }}
private-key: ${{ secrets.JEEVES_APP_PRIVATE_KEY }}
- name: Update out-of-date PR branches
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
gh pr list --repo "${{ github.repository }}" --base main --state open --json number \
--jq '.[].number' | \
while read -r pr; do
echo "Checking PR #$pr..."
gh pr update-branch --rebase --repo "${{ github.repository }}" "$pr" || true
done