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
41 changes: 41 additions & 0 deletions .github/workflows/sync-auto-merge-prs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Sync auto-merge PRs with develop

on:
schedule:
- cron: '0 0-5 * * *'
workflow_dispatch:

jobs:
sync-one-pr:
runs-on: ubuntu-latest
steps:
- name: Find and sync one behind auto-merge PR
env:
GH_TOKEN: ${{ secrets.PR_SYNC_PAT }}
run: |
PR_LIST=$(gh pr list \
--repo "$GITHUB_REPOSITORY" \
--base develop \
--state open \
--json number,title,autoMergeRequest,mergeStateStatus)

BEHIND=$(echo "$PR_LIST" | jq '[.[] | select(
.autoMergeRequest != null and
.mergeStateStatus == "BEHIND"
)]')

COUNT=$(echo "$BEHIND" | jq 'length')
echo "Found $COUNT auto-merge PR(s) behind develop"

if [ "$COUNT" -eq 0 ]; then
echo "Nothing to sync."
exit 0
fi

INDEX=$((RANDOM % COUNT))
PR_NUMBER=$(echo "$BEHIND" | jq --argjson i "$INDEX" '.[$i].number')
PR_TITLE=$(echo "$BEHIND" | jq -r --argjson i "$INDEX" '.[$i].title')

echo "Selected PR #$PR_NUMBER: $PR_TITLE"
gh pr update-branch "$PR_NUMBER" --repo "$GITHUB_REPOSITORY"
echo "Branch updated."
49 changes: 0 additions & 49 deletions .github/workflows/update-prs-with-develop.yml

This file was deleted.

Loading